diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php index 77c1eb4ef669b..ab78ae1494f22 100644 --- a/src/wp-includes/plugin.php +++ b/src/wp-includes/plugin.php @@ -488,6 +488,10 @@ function do_action( $hook_name, ...$arg ) { ++$wp_actions[ $hook_name ]; } + if ( 'shutdown' === $hook_name ) { + $wp_current_filter = array(); + } + // Do 'all' actions first. if ( isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $hook_name; diff --git a/tests/phpunit/tests/includes/helpers.php b/tests/phpunit/tests/includes/helpers.php index 5b9b83f463f94..674c937e633d6 100644 --- a/tests/phpunit/tests/includes/helpers.php +++ b/tests/phpunit/tests/includes/helpers.php @@ -287,6 +287,18 @@ public function test_die_handler_should_not_cause_doing_it_wrong_notice_without_ $this->assertEmpty( $this->caught_doing_it_wrong ); } + /** + * @ticket 62490 + */ + public function test_doing_action_shutdown() { + $this->expectException( 'WPDieException' ); + + add_action( 'foo', 'wp_die', 10, 0 ); + do_action( 'foo' ); + + $this->assertFalse( doing_action( 'foo' ) ); + } + /** * @ticket 45933 * @dataProvider data_die_process_input