[wp-trac] [WordPress Trac] #55998: Problem in do_action when sanitizing the args passed

WordPress Trac noreply at wordpress.org
Fri Jun 17 06:44:29 UTC 2022


#55998: Problem in do_action when sanitizing the args passed
--------------------------+-----------------------------
 Reporter:  salvamb       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.0
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 We are running a do_action and passing a parameter like this:

 {{{#!php
 <?php
 array (
   0 => (object)[
      'product_id' => '24',
      'order_item_id' => '210',
      'order_id' => '480',
      'order_item_name' => 'Ship Your Idea 2 - Green',
   ]
 );
 }}}


 And this array is being stripped by WordPress on plugin.php line 471 and
 passing only the inner object. So what is finally received on the action
 callbacks is:

 {{{#!php
 <?PHP
 (object)[
      'product_id' => '24',
      'order_item_id' => '210',
      'order_id' => '480',
      'order_item_name' => 'Ship Your Idea 2 - Green',
 ];
 }}}

 When I was expecting to receive an array and breaking forcing me to fix
 this on the callback.
 This doesn't happen in all cases. Only when the array passed has just one
 item inside. If it has more than one, it passes the array correctly.
 I understand this was done for backward compatibility but it shouldn't
 alter the params passed to the action or might have unexpected behaviors.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55998>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list