[wp-trac] [WordPress Trac] #16661: Deprecate do_action_ref_array()

WordPress Trac wp-trac at lists.automattic.com
Wed Mar 9 00:17:45 UTC 2011


#16661: Deprecate do_action_ref_array()
--------------------------------------+-----------------------------
 Reporter:  scribu                    |       Owner:
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  Future Release
Component:  General                   |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch 3.2-early php5  |
--------------------------------------+-----------------------------

Comment (by hakre):

 I think it's okay to review the use of `apply_filters_ref_array()` and
 `do_action_ref_array()` (Related: #16767), but please keep in mind that
 Call-time pass-by-reference has been deprecated since some time now. PHP
 5.3 does warnings.

 So as this was suggested in one of the patches (I pick this only as an
 example):

 `do_action( 'check_passwords', $user->user_login, &$pass1, &$pass2 );`

 Will trigger warnings which needs to be prevented.

 `do_action()` or `apply_filters()` are making use of `func_get_args()`
 which does not support php references
 ([http://www.php.net/manual/en/function.func-get-args.php see manual])
 which like the other `php func_*()` functions will always contain a copy
 of the argument anyway - even if call-time passed by reference as in the
 example above (!).

 This means that the wordpress *_ref_array() functions are indeed still
 usefull because they pass all parameters in form of an array that will
 contain the same references even if you create a copy of the array.
 '''Therefore those two functions `apply_filters_ref_array()` and
 `do_action_ref_array()` should not be deprecated for the moment.'''

 This would make this ticket invalid, however the usage of those two
 functions can still benefit from a review as how this ticket reported as
 well, we do not need to pass objects as references any longer. So part of
 the intention of this ticket looks still valid to me and I suggest to not
 close it as invalid but to adopt it a bit.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16661#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list