WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/26/2017 01:52:06 PM (17 months ago)
Author:
joehoyle
Message:

REST API: Return an error if the page number is out of bounds.

Return an error from the REST API if a page number larger than the total pages count is requested.

Props morganestes.
Fixes #39061.

File:
1 edited

Legend:

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

    r39954 r39967  
    826826        $response = $this->server->dispatch( $request );
    827827        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     828    }
     829
     830    /**
     831     * @ticket 39061
     832     */
     833    public function test_get_items_invalid_max_pages() {
     834        // Out of bounds
     835        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     836        $request->set_param( 'page', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
     837        $response = $this->server->dispatch( $request );
     838        $this->assertErrorResponse( 'rest_post_invalid_page_number', $response, 400 );
    828839    }
    829840
Note: See TracChangeset for help on using the changeset viewer.