Opened 7 years ago
Last modified 19 months ago
#47438 new defect (bug)
do_action will convert "single array object" as "object"
| Reported by: |
|
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)
Note: See
TracTickets for help on using
tickets.
this bug has been there since 2 years ago
see contributed notes here:
https://developer.wordpress.org/reference/functions/do_action/