Make WordPress Core

Opened 2 weeks ago

Last modified 14 hours ago

#49678 new defect (bug)

do_action default first parameter

Reported by: Tkama Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.3.2
Component: Plugins Keywords: dev-feedback
Focuses: Cc:


This code looks like bug: we don't pass any parameters to action but the first parameter is passed anyway and have the value (empty string). Why?

add_action( 'action_name', function( $first ){
        var_dump( $first );
} );

do_action( 'action_name' ); //> string(0) ""

Change History (2)

#1 @SergeyBiryukov
2 weeks ago

  • Component changed from General to Plugins

#2 @donmhico
14 hours ago

  • Keywords dev-feedback added

Hi @Tkama,

Navigating the codebase, seems like this line is responsible - https://core.trac.wordpress.org/browser/trunk/src/wp-includes/plugin.php#L472

While it's just easy to remove the if clause, i'm not sure if it won't introduce any compatibility issues.

Note: See TracTickets for help on using tickets.