[wp-hackers] passing references to do_action/apply_filters
Robert Deaton
false.hopes at gmail.com
Thu Aug 4 11:55:40 GMT 2005
A quick note, allow_call_time_pass_reference is "1" by default. While
it doesn't stop the warning, at least we know the code still works on
default installs for now.
On 8/4/05, Nikolay Bachiyski <nbachiyski at developer.bg> wrote:
> In newer default php.ini setups the value of
>
> allow_call_time_pass_reference (see http://uk2.php.net/ini.core)
>
> is Off, which does not allow to pass arguments by reference unless it is
> explicitly noted in the function's declaration.
>
> However, sometimes is is needed a hook to change the values of its
> arguments. For example see the patch for pre_ping hook
> (http://trac.wordpress.org/ticket/1489 and
> http://trac.wordpress.org/changeset/2743 ) and if
> allow_call_time_pass_reference is Off it causes a Warning: "Warning:
> Call-time pass-by-reference has been deprecated.." (see
> http://trac.wordpress.org/ticket/1547).
>
> Unfortunately there isn't an easy way to control whether
> do_action/apply_filter arguments are passed by reference of by value.
>
> Of course there are some dirty hacks, as for example using an array to
> pass all the variables:
>
> <?php
> function varargs_by_ref($arg_list = null) {
> if (is_array($arg_list)) {
> foreach ($arg_list as &$arg) {
> # do whatever you want with $arg...
> }
> }
> }
>
> $by_ref = 'to_be_midified_inside_func';
> $by_val = 'to_be_passed_by_value';
>
> varargs_by_ref(array('baba', &$by_ref, $by_value));
>
> ?>
>
> Any other suggestions?
>
> Nikolay.
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
--
--Robert Deaton
http://somethingunpredictable.com
More information about the wp-hackers
mailing list