Skip to content

Commit 5e11bd0

Browse files
committed
Tests: Restore the Abilities API setup filter stack.
Use `try`/`finally` around core ability and category registration so each simulated action is removed from `$wp_current_filter` even if registration throws. Follow-up to [64266]. Developed in: #14296 Props shailu25. See #65893. git-svn-id: https://develop.svn.wordpress.org/trunk@64362 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3ed38fa commit 5e11bd0

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ public static function set_up_before_class(): void {
2323
global $wp_current_filter;
2424

2525
// Ensure core abilities and categories are registered for these tests.
26+
// Pop in finally so a setup exception cannot leave the simulated action on the stack.
2627
$wp_current_filter[] = 'wp_abilities_api_categories_init';
27-
wp_register_core_ability_categories();
28-
array_pop( $wp_current_filter );
28+
try {
29+
wp_register_core_ability_categories();
30+
} finally {
31+
array_pop( $wp_current_filter );
32+
}
2933

3034
$wp_current_filter[] = 'wp_abilities_api_init';
31-
wp_register_core_abilities();
32-
array_pop( $wp_current_filter );
35+
try {
36+
wp_register_core_abilities();
37+
} finally {
38+
array_pop( $wp_current_filter );
39+
}
3340
}
3441

3542
/**

0 commit comments

Comments
 (0)