[wp-trac] [WordPress Trac] #50786: REST API: delete post from block editor triggers a warning

WordPress Trac noreply at wordpress.org
Mon Jul 27 18:44:28 UTC 2020

#50786: REST API: delete post from block editor triggers a warning
 Reporter:  manooweb                             |       Owner:
                                                 |  TimothyBlynJacobs
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  5.5
Component:  REST API                             |     Version:  trunk
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests dev-        |     Focuses:
  reviewed commit                                |
Changes (by TimothyBlynJacobs):

 * status:  assigned => closed
 * resolution:   => fixed


 In [changeset:"48642" 48642]:
 #!CommitTicketReference repository="" revision="48642"
 REST API: Fix warning when using `set_param()` on a JSON request with no

 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.

Ticket URL: <https://core.trac.wordpress.org/ticket/50786#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list