Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#55998 closed defect (bug) (duplicate)

Problem in do_action when sanitizing the args passed

Reported by: salvamb's profile salvamb Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.0
Component: Plugins Keywords:
Focuses: Cc:

Description

We are running a do_action and passing a parameter like this:

<?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
(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.

Change History (1)

#1 @SergeyBiryukov
3 years ago

  • Component changed from General to Plugins
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac!

Thanks for the report, we're already tracking this issue in #55133.

Note: See TracTickets for help on using tickets.