WordPress/wp-includes/rest-api
davidbaumwald 7a15b3353a REST API: Ensure args is an array of arrays in register_rest_route().
When calling `register_rest_route()`, the `args` parameter for a route should be an array of arrays.  However, some plugins/themes have passed an array of strings or key-value pairs which produces a PHP warning when `array_intersect_key` is used to filter the array keys based on an allowed list of schema keywords.

This change adds a check of the `args` parameter to ensure it's an array of arrays, presenting a `_doing_it_wrong` if any element of `args` is not an array and restructuring to an array of arrays.  This change also adds a unit test for the incorrect usage described above, expecting that a `_doing_it_wrong` is produced.

Props slaFFik, desrosj, apermo, AndrewNZ, aristath, poena, dovyp, timothyblynjacobs, Hinjiriyo, johnmark8080, nateallen.
Fixes #51986.
Built from https://develop.svn.wordpress.org/trunk@54339


git-svn-id: http://core.svn.wordpress.org/trunk@53898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-27 20:13:13 +00:00
..
endpoints Code Modernization: Fix null to non-nullable deprecation in WP_REST_Users_Controller::update_item(). 2022-09-26 21:46:09 +00:00
fields Code Modernization: Add AllowDynamicProperties attribute to all (parent) classes. 2022-09-12 15:47:14 +00:00
search Code Modernization: Add AllowDynamicProperties attribute to all (parent) classes. 2022-09-12 15:47:14 +00:00
class-wp-rest-request.php Code Modernization: Add AllowDynamicProperties attribute to all (parent) classes. 2022-09-12 15:47:14 +00:00
class-wp-rest-response.php Docs: Update spelling for inline comments in a few files. 2022-01-25 13:55:05 +00:00
class-wp-rest-server.php REST API: Ensure args is an array of arrays in register_rest_route(). 2022-09-27 20:13:13 +00:00