diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php index f64afba1baa2a..cccb7b3a3d35e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php @@ -435,9 +435,9 @@ protected function prepare_links( $id ) { ); if ( post_type_supports( $this->post_type, 'revisions' ) ) { - $revisions = wp_get_latest_revision_id_and_total_count( $id ); - $revisions_count = ! is_wp_error( $revisions ) ? $revisions['count'] : 0; - $revisions_base = sprintf( '/%s/%d/revisions', $base, $id ); + $revisions = wp_get_latest_revision_id_and_total_count( $id ); + $revisions_count = ! is_wp_error( $revisions ) ? $revisions['count'] : 0; + $revisions_base = sprintf( '/%s/%d/revisions', $base, $id ); $links['version-history'] = array( 'href' => rest_url( $revisions_base ), 'count' => $revisions_count, diff --git a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php index 127e638b772e9..9e580d5f3c978 100644 --- a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php @@ -66,7 +66,6 @@ class WP_REST_Global_Styles_Revisions_Controller_Test extends WP_Test_REST_Contr */ private $revision_3_id; - /** * Create fake data before our tests run. * @@ -225,11 +224,10 @@ public function set_up() { $this->revision_3_id = $this->revision_3->ID; } - /** - * @covers WP_REST_Global_Styles_Controller::register_routes - * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::register_routes */ public function test_register_routes() { $routes = rest_get_server()->get_routes(); @@ -241,9 +239,9 @@ public function test_register_routes() { } /** - * @covers WP_REST_Global_Styles_Controller::get_items - * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_missing_parent() { wp_set_current_user( self::$admin_id ); @@ -281,9 +279,9 @@ protected function check_get_revision_response( $response_revision_item, $revisi } /** - * @covers WP_REST_Global_Styles_Controller::get_items - * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items() { wp_set_current_user( self::$admin_id ); @@ -307,9 +305,9 @@ public function test_get_items() { } /** - * @covers WP_REST_Global_Styles_Controller::get_items - * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_eligible_roles() { wp_set_current_user( self::$second_admin_id ); @@ -339,9 +337,9 @@ public function test_get_items_eligible_roles() { } /** - * @covers WP_REST_Global_Styles_Controller::get_items with context arg. - * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items with context arg. */ public function test_get_item_embed_context() { wp_set_current_user( self::$admin_id ); @@ -360,9 +358,9 @@ public function test_get_item_embed_context() { } /** - * @covers WP_REST_Global_Styles_Controller::get_item_schema - * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_item_schema */ public function test_get_item_schema() { $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/global-styles/' . self::$global_styles_id . '/revisions' ); @@ -383,9 +381,9 @@ public function test_get_item_schema() { } /** - * @covers WP_REST_Global_Styles_Controller::get_item_permissions_check - * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_item_permissions_check */ public function test_get_item_permissions_check() { wp_set_current_user( self::$author_id ); @@ -401,6 +399,8 @@ public function test_get_item_permissions_check() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_pagination_header_of_the_first_page * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_pagination_header_of_the_first_page() { wp_set_current_user( self::$admin_id ); @@ -438,6 +438,8 @@ public function test_get_items_pagination_header_of_the_first_page() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_pagination_header_of_the_last_page * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_pagination_header_of_the_last_page() { wp_set_current_user( self::$admin_id ); @@ -474,6 +476,8 @@ public function test_get_items_pagination_header_of_the_last_page() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_invalid_per_page_should_error * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_invalid_per_page_should_error() { wp_set_current_user( self::$admin_id ); @@ -494,6 +498,8 @@ public function test_get_items_invalid_per_page_should_error() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_out_of_bounds_page_should_error * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_out_of_bounds_page_should_error() { wp_set_current_user( self::$admin_id ); @@ -521,6 +527,8 @@ public function test_get_items_out_of_bounds_page_should_error() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_invalid_max_pages_should_error * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_invalid_max_pages_should_error() { wp_set_current_user( self::$admin_id ); @@ -547,6 +555,8 @@ public function test_get_items_invalid_max_pages_should_error() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_default_query_should_fetch_all_revisons * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_default_query_should_fetch_all_revisons() { wp_set_current_user( self::$admin_id ); @@ -558,13 +568,14 @@ public function test_get_items_default_query_should_fetch_all_revisons() { $this->assertCount( $expected_count, $response->get_data() ); } - /** * Tests that 'offset' query shouldn't work without 'per_page' (fallback -1). * * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_offset_should_not_work_without_per_page * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_offset_should_not_work_without_per_page() { wp_set_current_user( self::$admin_id ); @@ -584,6 +595,8 @@ public function test_get_items_offset_should_not_work_without_per_page() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_offset_should_work_with_per_page * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_offset_should_work_with_per_page() { wp_set_current_user( self::$admin_id ); @@ -609,6 +622,8 @@ public function test_get_items_offset_should_work_with_per_page() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_offset_should_take_priority_over_page * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_offset_should_take_priority_over_page() { wp_set_current_user( self::$admin_id ); @@ -636,6 +651,8 @@ public function test_get_items_offset_should_take_priority_over_page() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_total_revisions_offset_should_return_empty_data * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_total_revisions_offset_should_return_empty_data() { wp_set_current_user( self::$admin_id ); @@ -662,6 +679,8 @@ public function test_get_items_total_revisions_offset_should_return_empty_data() * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_out_of_bound_offset_should_error * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_out_of_bound_offset_should_error() { wp_set_current_user( self::$admin_id ); @@ -688,6 +707,8 @@ public function test_get_items_out_of_bound_offset_should_error() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_impossible_high_number_offset_should_error * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_impossible_high_number_offset_should_error() { wp_set_current_user( self::$admin_id ); @@ -714,6 +735,8 @@ public function test_get_items_impossible_high_number_offset_should_error() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_invalid_offset_should_error * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_invalid_offset_should_error() { wp_set_current_user( self::$admin_id ); @@ -741,6 +764,8 @@ public function test_get_items_invalid_offset_should_error() { * Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_out_of_bounds_page_should_not_error_if_offset * * @ticket 58524 + * + * @covers WP_REST_Global_Styles_Controller::get_items */ public function test_get_items_out_of_bounds_page_should_not_error_if_offset() { wp_set_current_user( self::$admin_id );