WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#47438 new defect (bug)

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

Reported by: erikdemarco Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.1.1
Component: Plugins Keywords:
Focuses: Cc:
PR Number:

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 (2)

#1 @erikdemarco
5 months ago

this bug has been there since 2 years ago

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

#2 @SergeyBiryukov
5 months ago

  • Component changed from General to Plugins
Note: See TracTickets for help on using tickets.