[wp-trac] [WordPress Trac] #29070: Calling remove_all_filters() causes has_filter() with no $function_to_check to always return true

WordPress Trac noreply at wordpress.org
Sun Aug 3 20:07:59 UTC 2014


#29070: Calling remove_all_filters() causes has_filter() with no $function_to_check
to always return true
-------------------------------------+--------------------
 Reporter:  pseudoxiah               |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  4.0
Component:  Plugins                  |     Version:  trunk
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+--------------------
Changes (by boonebgorges):

 * keywords:  needs-patch needs-unit-tests => has-patch needs-testing


Comment:

 > Isn't this the expected behaviour? remove_all_filters() removes all of
 the hooks from a filter, but not the filter itself.

 `has_filter()` should return true if there are filter callbacks registered
 for that particular hook. After `remove_all_filters()`, `has_filter()`
 should return false.

 I was able to reproduce the error only by adding filters at different
 priorities, and then calling `remove_all_filters( $hook, $priority )` for
 each priority separately. This does leave some empty arrays laying around
 as a result of r28883.

 Attached patch has a unit test that demonstrates the bug, as well as a
 cleaned up version of pseudoxiah's original suggested solution. Test
 passes before r28883, fails on current trunk, passes with the fix. Entire
 test suite passes with the patch.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29070#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list