diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php
index 823b4b5..2fba490 100755
a
|
b
|
final class WP_Hook implements Iterator, ArrayAccess { |
287 | 287 | $this->current_priority[ $nesting_level ] = $priority = current( $this->iterations[ $nesting_level ] ); |
288 | 288 | |
289 | 289 | foreach ( $this->callbacks[ $priority ] as $the_ ) { |
290 | | if( ! $this->doing_action ) { |
| 290 | if ( ! $this->doing_action ) { |
291 | 291 | $args[ 0 ] = $value; |
292 | 292 | } |
293 | 293 | |
294 | 294 | // Avoid the array_slice if possible. |
295 | | if ( $the_['accepted_args'] == 0 ) { |
296 | | $value = call_user_func_array( $the_['function'], array() ); |
297 | | } elseif ( $the_['accepted_args'] >= $num_args ) { |
298 | | $value = call_user_func_array( $the_['function'], $args ); |
| 295 | if ( is_numeric( $the_['accepted_args'] ) && $the_['accepted_args'] == 0 ) { |
| 296 | $call_args = array(); |
| 297 | } elseif ( $the_['accepted_args'] > 0 && $the_['accepted_args'] < $num_args ) { |
| 298 | $call_args = array_slice( $args, 0, (int) $the_['accepted_args'] ); |
299 | 299 | } else { |
300 | | $value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int)$the_['accepted_args'] ) ); |
| 300 | $call_args = $args; |
301 | 301 | } |
| 302 | |
| 303 | $value = call_user_func_array( $the_['function'], $call_args ); |
302 | 304 | } |
303 | 305 | } while ( false !== next( $this->iterations[ $nesting_level ] ) ); |
304 | 306 | |
diff --git a/tests/phpunit/tests/hooks/do_action.php b/tests/phpunit/tests/hooks/do_action.php
index b810d46..c7255f6 100755
a
|
b
|
class Tests_WP_Hook_Do_Action extends WP_UnitTestCase { |
139 | 139 | $this->assertSame( 'a1-b1b3-a2a3', $this->action_output ); |
140 | 140 | } |
141 | 141 | |
| 142 | public function test_can_pass_all_args() { |
| 143 | $a = new MockAction(); |
| 144 | $callback = array( $a, 'action' ); |
| 145 | $hook = new WP_Hook(); |
| 146 | $tag = rand_str(); |
| 147 | $priority = rand( 1, 100 ); |
| 148 | $accepted_args = -1; // will pass all |
| 149 | |
| 150 | $args = array(); |
| 151 | for ( $i = 1; $i <= rand( 5, 10 ); $i++ ) { |
| 152 | $args[] = rand_str(); |
| 153 | } |
| 154 | |
| 155 | $hook->add_filter( $tag, $callback, $priority, $accepted_args ); |
| 156 | $hook->do_action( $args ); |
| 157 | |
| 158 | $called_args = $a->get_args(); |
| 159 | |
| 160 | $this->assertEquals( count( $args ), count( $called_args[0] ) ); |
| 161 | } |
| 162 | |
142 | 163 | public function _filter_do_action_doesnt_change_value1( $value ) { |
143 | 164 | $this->action_output .= $value . 1; |
144 | 165 | return 'x1'; |