Make WordPress Core

Opened 6 years ago

Last modified 9 months ago

#47438 new defect (bug)

do_action will convert "single array object" as "object"

Reported by: erikdemarco's profile erikdemarco Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.1.1
Component: Plugins Keywords:
Focuses: Cc:

Description

/* Correct if $object is not object*/
$orders = array();
$orders[] = 'abc';

do_action( 'action123', $orders); 

add_action('action123', 'func123');
function func123($orders){
	//$orders will be array here (CORRECT)
}


/* BUG: if $orders is an object */
$orders = array();
$orders[]=new stdClass();
$orders->name='Order1';

do_action( 'action123', $orders); 

add_action('action123', 'func123');
function func123($orders){
	//$orders will be non-array here (BUG?)
}

Note:
This will run correctly if $orders[] is not object

Change History (4)

#1 @erikdemarco
6 years ago

this bug has been there since 2 years ago

see contributed notes here:
https://developer.wordpress.org/reference/functions/do_action/

#2 @SergeyBiryukov
6 years ago

  • Component changed from General to Plugins

#3 @dlh
5 years ago

#48382 was marked as a duplicate.

#4 @JPry
9 months ago

It appears that this behavior is intentional. This was put in place due to #48312 (as seen in change [46568]).

Note: See TracTickets for help on using tickets.