Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r39954 r39967 328 328 329 329 $max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] ); 330 331 if ( $page > $max_pages && $total_posts > 0 ) { 332 return new WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) ); 333 } 334 330 335 $response = rest_ensure_response( $posts ); 331 336 -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r39954 r39967 826 826 $response = $this->server->dispatch( $request ); 827 827 $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 ); 828 839 } 829 840
Note: See TracChangeset
for help on using the changeset viewer.