Make WordPress Core

Opened 23 months ago

Last modified 2 months ago

#20920 new defect (bug)

Removing all hooks too aggressive if a priority number is given

Reported by: GeertDD Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.3.2
Component: Plugins Keywords: has-patch needs-unit-tests
Focuses: Cc:


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.


global $wp_filter;

add_action('my_action', 'callback_foo');
add_action('my_action', 'callback_bar', 20);

// At this point only callback_foo is left. Fine.
remove_all_actions('my_action', 20);

// Exactly the same function call as above,
// but now all hooks bound to my_action are removed!
remove_all_actions('my_action', 20);

Calling remove_all_filters() or remove_all_actions() with a priority should never remove hooks with another priority.

Attachments (1)

remove_all_filters.diff (549 bytes) - added by GeertDD 23 months ago.

Download all attachments as: .zip

Change History (4)

comment:1 SergeyBiryukov22 months ago

  • Component changed from General to Plugins
  • Milestone changed from Awaiting Review to Future Release

comment:2 mordauk3 months ago

Seems sane to me.

comment:3 nacin2 months ago

  • Keywords needs-unit-tests added
Note: See TracTickets for help on using tickets.