WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/25/2017 12:53:47 AM (3 years ago)
Author:
pento
Message:

REST API: Always add index.php to the REST URL when pretty permalinks are disabled.

When pretty permalinks are disabled, the web server will internally forward requests to index.php. Unfortunately, nginx only forwards HTTP/1.0 methods: PUT, PATCH, and DELETE methods will return a 405 error.

To work around this nginx behaviour, including index.php in the REST URL skips the internal redirect.

Merges 41139 to the 4.8 branch.
Fixes #40886.

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/tests/phpunit/tests/oembed/controller.php

    r41049 r41140  
    417417
    418418    function test_get_oembed_endpoint_url() {
    419         $this->assertEquals( home_url() . '/?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url() );
    420         $this->assertEquals( home_url() . '/?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'json' ) );
    421         $this->assertEquals( home_url() . '/?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
     419        $this->assertEquals( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url() );
     420        $this->assertEquals( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'json' ) );
     421        $this->assertEquals( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
    422422
    423423        $post_id     = $this->factory()->post->create();
     
    425425        $url_encoded = urlencode( $url );
    426426
    427         $this->assertEquals( home_url() . '/?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded, get_oembed_endpoint_url( $url ) );
    428         $this->assertEquals( home_url() . '/?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) );
     427        $this->assertEquals( home_url() . '/index.php?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded, get_oembed_endpoint_url( $url ) );
     428        $this->assertEquals( home_url() . '/index.php?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) );
    429429    }
    430430
Note: See TracChangeset for help on using the changeset viewer.