[wp-hackers] call time pass by reference (PHP 5.4 in-compatibilities)

Vid Luther vid at zippykid.com
Fri Dec 28 23:15:22 UTC 2012


On Fri, Dec 28, 2012 at 4:55 PM, Andrew Nacin <wp at andrewnacin.com> wrote:

> I'd have to see specific instances to be sure, but generally speaking,
> this is the result of passing an object by reference to an action or
> filter.
> In core, we have done this with do_action_ref_array() and
> apply_filters_ref_array(), rather with do_action() or apply_filters().
>
>
<copy-pasta from debug log>
PHP Fatal error:  Call-time pass-by-reference has been removed; If you
would like to pass argument by reference, modify the declaration of
apply_filters(). in /htdocs/wp-content/plugins/buddypress/bp-activity.php
on line 332
[28-Dec-2012 22:10:35 UTC] PHP Fatal error:  Call-time pass-by-reference
has been removed; If you would like to pass argument by reference, modify
the declaration of apply_filters(). in
/htdocs/wp-content/plugins/buddypress/bp-activity.php on line 608
[28-Dec-2012 22:10:51 UTC] PHP Fatal error:  Call-time pass-by-reference
has been removed; If you would like to pass argument by reference, modify
the declaration of do_action(). in
/htdocs/wp-content/plugins/buddypress/bp-activity/bp-activity-classes.php
on line 49
[28-Dec-2012 22:31:10 UTC] PHP Fatal error:  Call-time pass-by-reference
has been removed; If you would like to pass argument by reference, modify
the declaration of apply_filters(). in
/htdocs/wp-content/plugins/buddypress/bp-activity/bp-activity-classes.php
on line 51
.. and so on

</copy-pasta from debug.log>

I looked a little more closely, and realized they have a hacked version of
1.2.6 running in prod..

Let me look a little more closely, this may be something I need to work
with JJJ on directly on the BuddyPress side.






> In PHP 5.x, this is no longer needed for objects, and it doesn't make
> much sense to need a reference for anything besides objects, anyway.
> So, we are no longer using apply_filters_ref_array() and
> do_action_ref_array() in core. We should probably "soft-deprecate" these
> functions with a message in the Codex.
>
> However, *we can't remove existing instances* of _ref_array() calls
> without breaking plugins. Plugin callbacks tied to existing _ref_array()
> actions might be explicitly asking for their value to be passed by
> reference, like so:
>
> do_action_ref_array( 'example_hook', array( &$var ) );
> add_action( 'example_hook', 'my_callback' );
> function my_callback( &$var ) {}
>
> If they suddenly stop receiving the variable by reference, an E_WARNING
> is issued. That's no fun.
>



-- 
Vid Luther
CEO and Founder
ZippyKid
Managed Wordpress Hosting
http://zippykid.com/
210-789-0369


More information about the wp-hackers mailing list