[wp-trac] [WordPress Trac] #49678: do_action default first parameter
WordPress Trac
noreply at wordpress.org
Tue Jul 1 11:28:46 UTC 2025
#49678: do_action default first parameter
--------------------------+------------------------------
Reporter: Tkama | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 5.3.2
Severity: normal | Resolution: wontfix
Keywords: dev-feedback | Focuses:
--------------------------+------------------------------
Changes (by callumbw95):
* status: new => closed
* resolution: => wontfix
Comment:
Hi @Tkama,
I have taken a quick look at this and the `do_action()` function has been
a fundamental part of the WordPress plugin API for many major releases,
and as of such countless plugins and themes rely on its existing
behaviour.
This ticket proposes changing the default value passed to an action's
callback. Currently, when `do_action( 'hook_name' )` is called without any
arguments, the callback function receives an empty string `""` as its
first parameter, and I believe the intent here is to pass `null` when
nothing is passed.
While this change would create more consistency with the `apply_filters`
API, it would introduce a significant backward-compatibility break.
Developers have relied on the default empty string behavior for years,
using checks like `if ( empty( $param ) )` or `if ( '' === $param )` to
determine if a value was explicitly passed to `do_action`. Changing this
fundamental behavior would alter the logic in a vast number of plugins and
themes, leading to unpredictable results and bugs.
For these reasons, I'm closing this ticket as `wontfix`, but of course if
you have any further feedback please feel free to reopen the ticket.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49678#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list