[wp-trac] [WordPress Trac] #44406: Mismatch in the default value of the optional replacement argument in do_action_deprecated(), apply_filters_deprecated() and _deprecated_hook()

WordPress Trac noreply at wordpress.org
Wed Jun 20 03:22:56 UTC 2018


#44406: Mismatch in the default value of the optional replacement argument in
do_action_deprecated(), apply_filters_deprecated() and _deprecated_hook()
--------------------------+-----------------------------
 Reporter:  birgire       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.6
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 There's a mismatch in the default value of the optional ''replacement''
 argument in the functions {{{do_action_deprecated()}}},
 {{{apply_filters_deprecated()}}}  and {{{_deprecated_hook()}}}.

 We have:
 {{{
 function do_action_deprecated( ..., $replacement = false, ... ) { ... }

 function apply_filters_deprecated( ..., $replacement = false, ... ) { ...
 }
 }}}

 but then on the other hand:

 {{{
 function _deprecated_hook( ..., $replacement = null, ... ) { ... }
 }}}

 containing a {{{! is_null( $replacement ) }}} check.

 ''How to fix:''

 I think adjusting the private function {{{_deprecated_hook()}}}, could be
 a safer route, as it's not supposed to be used by plugins or themes.
 Either adjust the optional input value to {{{false}}}, or e.g. replace
 {{{! is_null( $replacement )}}} with  {{{! $replacement }}} to handle
 both.

 ''How to replicate - Example:''

 {{{
 add_action( 'init', function() {
     add_action( 'foo_action', 'foo_action_callback' );
     do_action_deprecated( 'foo_action', array( '123' ), '4.9' );
     remove_action( 'foo_action', 'foo_action_callback' );
 } );

 function foo_action_callback( $var ) {
 }

 }}}

 ''Actual message:
 ''
 {{{
 foo_action is deprecated since version 4.9! Use instead.

 }}}

 ''Expected message:
 ''
 {{{
 foo_action is deprecated since version 4.9 with no alternative available.

 }}}

 Related ticket #10441 and changeset [37861]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44406>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list