Opened 14 years ago
Closed 12 years ago
#20920 closed defect (bug) (fixed)
Removing all hooks too aggressive if a priority number is given
| Reported by: | GeertDD | Owned by: | boonebgorges |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.2 |
| Component: | Plugins | Version: | 3.3.2 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
When you call remove_all_filters() or remove_all_actions() with a priority number (second parameter), all hooks get removed if none is found with the given priority.
Example:
<?php global $wp_filter; add_action('my_action', 'callback_foo'); add_action('my_action', 'callback_bar', 20); var_dump($wp_filter['my_action']); // At this point only callback_foo is left. Fine. remove_all_actions('my_action', 20); var_dump($wp_filter['my_action']); // Exactly the same function call as above, // but now all hooks bound to my_action are removed! remove_all_actions('my_action', 20); var_dump($wp_filter['my_action']);
Calling remove_all_filters() or remove_all_actions() with a priority should never remove hooks with another priority.
Attachments (3)
Change History (10)
#4
@
12 years ago
- Keywords dev-feedback added; needs-unit-tests removed
The 20920.diff patch fixes the issue and includes supporting unit tests.
Cheers,
Derek
#5
@
12 years ago
- Keywords dev-feedback removed
- Milestone Future Release → 4.2
20920.2.diff reverses the if statement to make it a bit easier to read, and gives the unit test a more accurate name.
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Seems sane to me.