WordPress/wp-includes/rest-api
TimothyBlynJacobs 86ea4f0838 REST API: Fix warning when using `set_param()` on a JSON request with no body.
In [47559] the `WP_REST_Request::set_param()` method was adjusted to try and overwrite an existing parameter definition before forcing the value in the first parameter slot. If `set_param()` was called on a request with an `application/json` content type and an empty body, a PHP warning would be issued. This was due to the JSON parameter type not being set to an array when the body is empty.

This commit avoids the warning by adding an `is_array()` check before calling `array_key_exists`. Ideally, `WP_REST_Reuest::parse_json_params()` would set the JSON parameter type to an empty array in this case, but that is too large of a change at this point in the cycle.

Props manooweb.
Fixes #50786.

Built from https://develop.svn.wordpress.org/trunk@48642


git-svn-id: http://core.svn.wordpress.org/trunk@48404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-27 18:46:05 +00:00
..
endpoints REST API: Install plugin translations after the plugin install. This only installs for the plugin in question, not all plugins. 2020-07-27 18:31:06 +00:00
fields Docs: Synchronize and correct documentation for various metadata functions and filters. 2020-07-09 11:26:07 +00:00
search REST API: Use new `rest_get_route_for_post()` in the post search handler. 2020-07-07 15:31:02 +00:00
class-wp-rest-request.php REST API: Fix warning when using `set_param()` on a JSON request with no body. 2020-07-27 18:46:05 +00:00
class-wp-rest-response.php Docs: Improve inline comments per the documentation standards. 2020-01-29 00:45:18 +00:00
class-wp-rest-server.php Docs: Further corrections and improvements to various inline docblocks. 2020-07-23 07:39:02 +00:00