[wp-trac] [WordPress Trac] #45374: apply_filters_ref_array() no longer passes arguments by reference
WordPress Trac
noreply at wordpress.org
Mon Nov 19 18:14:55 UTC 2018
#45374: apply_filters_ref_array() no longer passes arguments by reference
------------------------------------------+------------------------------
Reporter: johnbillion | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 4.7
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+------------------------------
Comment (by jbrinley):
This didn't change with 4.7. From the pre-4.7 `do_action_ref_array()`,
which hasn't changed much since 2.2 (see #3875):
{{{
call_user_func_array($the_['function'], array_slice($args, 0, (int)
$the_['accepted_args']));
}}}
Here's a simplified example to show that we get the same warning:
https://3v4l.org/qeUZt
{{{#!php
<?php
function do_action_ref_array( $callback, $args ) {
call_user_func_array( $callback, array_slice( $args, 0, 2 ) );
}
$function = function( $arg1, &$arg2 ) {
return $arg1;
};
$args = [1, 2, 3];
do_action_ref_array( $function, $args );
}}}
Before 2.2, you could use call-time pass-by-reference to pass your
reference through to the callbacks, but that's not supported in modern
PHP.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45374#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list