Make WordPress Core


Ignore:
Timestamp:
10/26/2016 09:36:29 PM (7 years ago)
Author:
rachelbaker
Message:

REST API: Remove experimental filter wrapper parameter from the Posts Controller class.

Hiding WP_Query params under the filter key (instead of allowing them to be top-level params) was one of our biggest complaints from users of v1 of our REST API. This walks back the re-introduction of the filter param during Beta 15, which introduced an "inconsistent mess" and "exposing WP_Query through filter has and will continue to be difficult to support." See https://github.com/WP-API/WP-API/issues/2799.

Props websupporter, rachelbaker.
Fixes #38378.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php

    r38832 r38968  
    6060            'context',
    6161            'exclude',
    62             'filter',
    6362            'include',
    6463            'menu_order',
     
    180179        $draft_id = $this->factory->post->create( array( 'post_status' => 'draft', 'post_type' => 'page' ) );
    181180        $request = new WP_REST_Request( 'GET', '/wp/v2/pages' );
    182         $request->set_param( 'filter', array( 'post_status' => 'draft' ) );
    183         $response = $this->server->dispatch( $request );
    184         $data = $response->get_data();
    185         $this->assertCount( 1, $data );
    186         $this->assertEquals( $page_id, $data[0]['id'] );
     181        $request->set_param( 'status', 'draft' );
     182        $response = $this->server->dispatch( $request );
     183        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     184
    187185        // But they are accessible to authorized users
    188186        wp_set_current_user( $this->editor_id );
Note: See TracChangeset for help on using the changeset viewer.