WordPress.org

Make WordPress Core

Opened 23 months ago

Last modified 3 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:

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 (1)

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

Download all attachments as: .zip

Change History (4)

comment:1 SergeyBiryukov23 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 nacin3 months ago

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