Opened 5 years ago
Closed 5 years ago
#44638 closed defect (bug) (duplicate)
Bug in do_action
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.9.7 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
<?php $user_id = 1928; class test_object { public $ID; public $plugin_id; public function __construct ( $_id, $_plugin_id ) { $this->ID = $_id; $this->plugin_id = $_plugin_id; } } $_object = new test_object( 53, 1 ); $_products = array( 0 => $_object ); $order = wc_get_order( 8619 ); echo print_r( $_products, true ); add_action( '_add_items_to_order', 'fn_add_items_to_order' , 10, 3); function fn_add_items_to_order( $_products, $order, $user_id ) { echo print_r( $_products, true ); } echo '<br>do_action' . '<br>' ; do_action( '_add_items_to_order', $_products, $order, $user_id ); echo '<br> <br>apply_filters<br>' ; apply_filters( '_add_items_to_order', $_products, $order, $user_id );
Result:
<?php Array ( [0] => test_object Object ( [ID] => 53 [plugin_id] => 1 ) ) do_action: test_object Object ( [ID] => 53 [plugin_id] => 1 ) apply_filters: Array ( [0] => test_object Object ( [ID] => 53 [plugin_id] => 1 ) )
PS.
do_action works correct if array contains more than 1 item.
Regards, Oleksandr Kramer
Change History (1)
Note: See
TracTickets for help on using
tickets.
Duplicate of #40284.