Skip to content

Commit

Permalink
62490 doing_action returns incorrect results in shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Nov 20, 2024
1 parent 654475f commit 43258b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/wp-includes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions tests/phpunit/tests/includes/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,16 @@ 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() {
add_action( 'foo', 'wp_die', 10, 0 );
do_action( 'foo' );

$this->assertFalse( doing_action( 'foo' ) );
}

/**
* @ticket 45933
* @dataProvider data_die_process_input
Expand Down

0 comments on commit 43258b6

Please sign in to comment.