[wp-trac] [WordPress Trac] #42752: Rest api - can not convert string to array notice

WordPress Trac noreply at wordpress.org
Wed Nov 29 23:39:43 UTC 2017


#42752: Rest api - can not convert string to array notice
--------------------------+------------------------------
 Reporter:  steffanhalv   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  REST API      |     Version:  4.9
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  rest-api
--------------------------+------------------------------

Old description:

> Please see link for details:
>
> https://github.com/woocommerce/woocommerce/issues/17954#issuecomment-348028093
>
> Thx

New description:

 A PHP Notice can be generated on REST API requests
 {{{
 Notice: Array to string conversion in wp-includes/class-wp.php on line 305
 }}}

 One Request which can be used to trigger it is this:
 {{{
 http://localhost:9001/?_method=PUT&downloads[0][file]=http://localhost:9001
 /wp-
 content/uploads/2017/11/1600x1600___112808_1600x1600_v1-26.png&downloads[0][name]=1600x1600___112808_1600x1600_v1-26-png&downloads[1][file]=http://localhost:9001
 /wp-
 content/uploads/2017/11/1600x1600___pgs_es_spez_13_top_1600x1600_v1-167.png&downloads[1][name]=1600x1600___pgs_es_spez_13_top_1600x1600_v1-167-png
 }}}


 ----


 Please see link for details:

 https://github.com/woocommerce/woocommerce/issues/17954#issuecomment-348028093

 Thx

--

Comment (by dd32):

 Hi @steffanhalv,

 I've updated the description here to have a bit of the information from
 your woocommerce ticket for ease of searching.

 This specific case is because something on your site appears to be
 defining `downloads` as a Query Parameter (which can only be strings),
 also using that parameter in the `$_GET` variables of a REST API request
 causes this kind of notice.

 It may also cause the REST API request to return different results
 depending on what the plugin actually does.

 I'm fairly certain this is a duplicate of another ticket, which I can't
 find right now - something about checking for `is_scalar()` in
 `parse_request()`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42752#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list