REST API: Fixes /wp/v2/pattern-directory/patterns endpoint response for slug parameter.

[53218] introduced a bug of a wrong response from the `wp/v2/pattern-directory/patterns` endpoint with a `slug` parameter. As the response is cached, it can result in an incorrect list of available patterns supported by the current theme.

This commit resolves by:

* Limiting the `slug` to an `array` in the query parameters.
* When set, parsing and sorting the slug(s) and then serializing the sorted query args as part of the hashed transient keys.

Props antonvlasenko, timothyblynjacobs, spacedmonkey, costdev, hellofromTonya.

Follow-up to [53218], [53152], [51208].
Fixes #55617.

git-svn-id: https://develop.svn.wordpress.org/trunk@53333 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2022-05-02 13:58:48 +00:00
parent 9e6e4b5893
commit dc3204ec1d
3 changed files with 149 additions and 17 deletions
+5
View File
@@ -10385,6 +10385,11 @@ mockedApiResponse.Schema = {
"type": "integer",
"minimum": 1,
"required": false
},
"slug": {
"description": "Limit results to those matching a pattern (slug).",
"type": "array",
"required": false
}
}
}