[wp-trac] [WordPress Trac] #62490: doing_action wrong in shutdown
WordPress Trac
noreply at wordpress.org
Wed Nov 20 18:11:22 UTC 2024
#62490: doing_action wrong in shutdown
-------------------------------------------------+-------------------------
Reporter: kkmuffme | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: General | Version:
Severity: minor | Resolution:
Keywords: has-patch has-unit-tests reporter- | Focuses:
feedback |
-------------------------------------------------+-------------------------
Comment (by kkmuffme):
"doing_action" implies that the hook is currently being executed, which
means you could add an action on it.
But with shutdown this will never happen.
e.g.
{{{#!php
<?php
add_action( 'init', 'wp_die', 10, 0 );
function last_this() {
if ( doing_action( 'init' ) ) {
add_action( 'init', 'foo', 20 );
}
}
add_action( 'shutdown', 'last_this', 10, 0 );
function foo() {
echo "foo";
}
}}}
It will never echo "foo" in that case
Additionally, the current behavior will keep the hooks after shutdown too.
e.g.
{{{#!php
<?php
function first_this() {
register_shutdown_function( 'my_shutdown' );
wp_die();
}
add_action( 'init', 'first_this', 10, 0 );
function my_shutdown() {
// this will be "init" - but no "init" processing will take place at
all at that point, since we are AFTER "shutdown"
trigger_error( current_action(), E_USER_WARNING );
}
function last_this() {
// this will be "shutdown"
trigger_error( current_action(), E_USER_WARNING );
}
add_action( 'shutdown', 'last_this', 10, 0 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62490#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list