[wp-trac] [WordPress Trac] #14881: do_action should not pass empty string by default

WordPress Trac wp-trac at lists.automattic.com
Wed Sep 15 20:44:56 UTC 2010

#14881: do_action should not pass empty string by default
 Reporter:  nacin         |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Plugins       |     Version:                 
 Severity:  normal        |    Keywords:  has-patch      
 function test( $a = true ) {
    var_dump( $a );
 add_action( 'test', 'test' );
 add_action( 'test', 'test', 10, 0 );
 do_action( 'test' );
 First example is bool(true), but the second is a zero-length string.

 In this case, since do_action() is not passing any arguments, then no
 arguments should be passed to test() -- even if by default, one argument
 gets passed.

 The issue here is how do_action() is defined: `function do_action( $tag,
 $arg = '' );`. There's our zero-length string. Of note, apply_filters()
 does not have this same issue.

 The solution looks something like what I have attached. Has yet to be

 Of note, this does not appear to have any direct implications for passing
 all args by default, as proposed in #14671, but I wanted to reference it

Ticket URL: <http://core.trac.wordpress.org/ticket/14881>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list