Opened 7 years ago
Last modified 2 years ago
#47438 new defect (bug)
do_action will convert "single array object" as "object"
| Reported by: | erikdemarco | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Plugins | Version: | 5.1.1 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
this bug has been there since 2 years ago
see contributed notes here:
https://developer.wordpress.org/reference/functions/do_action/