From 1120502b7e8c561ad108f3d15f83782e5c7254b4 Mon Sep 17 00:00:00 2001 From: ramon Date: Wed, 3 Jan 2024 12:21:26 +1100 Subject: [PATCH] Excluding search, include and exclude from the collection query params Excluding order and order by from the collection query params Comment --- ...est-global-styles-revisions-controller.php | 18 +++++++ ...est-global-styles-revisions-controller.php | 2 +- tests/qunit/fixtures/wp-api-generated.js | 48 ------------------- 3 files changed, 19 insertions(+), 49 deletions(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php index c3c58b8bf1dee..b4a459665661d 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php @@ -311,4 +311,22 @@ public function get_item_schema() { return $this->add_additional_fields_schema( $this->schema ); } + + /** + * Retrieves the query params for collections. + * Removes params that are not supported by global styles revisions. + * + * @since 6.5.0 + * + * @return array Collection parameters. + */ + public function get_collection_params() { + $query_params = parent::get_collection_params(); + unset( $query_params['exclude'] ); + unset( $query_params['include'] ); + unset( $query_params['search'] ); + unset( $query_params['order'] ); + unset( $query_params['orderby'] ); + return $query_params; + } } 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 ec6239590e007..78e0443d975da 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 @@ -792,7 +792,7 @@ public function test_get_items_out_of_bounds_page_should_not_error_if_offset() { * @doesNotPerformAssertions */ public function test_context_param() { - // Controller does not implement test_context_param(). + // Controller does not implement get_context_param(). } /** diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index 38ff5b8a0e306..ef8e53d4bb508 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -10035,58 +10035,10 @@ mockedApiResponse.Schema = { "maximum": 100, "required": false }, - "search": { - "description": "Limit results to those matching a string.", - "type": "string", - "required": false - }, - "exclude": { - "description": "Ensure result set excludes specific IDs.", - "type": "array", - "items": { - "type": "integer" - }, - "default": [], - "required": false - }, - "include": { - "description": "Limit result set to specific IDs.", - "type": "array", - "items": { - "type": "integer" - }, - "default": [], - "required": false - }, "offset": { "description": "Offset the result set by a specific number of items.", "type": "integer", "required": false - }, - "order": { - "description": "Order sort attribute ascending or descending.", - "type": "string", - "default": "desc", - "enum": [ - "asc", - "desc" - ], - "required": false - }, - "orderby": { - "description": "Sort collection by object attribute.", - "type": "string", - "default": "date", - "enum": [ - "date", - "id", - "include", - "relevance", - "slug", - "include_slugs", - "title" - ], - "required": false } } }