[wp-trac] [WordPress Trac] #17817: do_action/apply_filters/etc. recursion on same filter kills underlying call

WordPress Trac noreply at wordpress.org
Thu Feb 12 03:27:11 UTC 2015


#17817: do_action/apply_filters/etc. recursion on same filter kills underlying call
-------------------------------------------------+-------------------------
 Reporter:  kernfel                              |       Owner:
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  4.2
Component:  Plugins                              |     Version:  2.2
 Severity:  normal                               |  Resolution:
 Keywords:  dev-feedback has-unit-tests has-     |     Focuses:
  patch 4.2-early                                |
-------------------------------------------------+-------------------------

Comment (by jbrinley):

 Followup to discussion in today's dev chat:

 I've reviewed every instance of `$wp_filter` that can be found at
 https://github.com/search?q=%24wp_filter+user%3Awp-plugins&type=Code (it's
 a little finicky, so if no results load refresh and you may get some).
 Most instances are not a cause for concern; they're already compatible
 thanks to `IteratorAggregate` or `ArrayAccess`. I did find a handful of
 cases that would have compatibility issues:

 Group 1 - Plugins that are messing with the `$wp_filter` global to work
 around this very issue. I only found one example here.

 * https://github.com/wp-plugins/badgeos/blob/master/includes/rules-
 engine.php#L165

 Group 2 - Plugins that do an `is_array()` check on a member of the
 `$wp_filter` global. Again, I found one example (and it's within debug
 tools for a plugin).

 * https://github.com/wp-plugins/event-espresso-
 decaf/blob/master/core/helpers/EEH_Debug_Tools.helper.php#L81

 Group 3 - Plugins that directly unset individual callbacks instead of
 using `remove_action()` / `remove_filter()` (this doesn't work because
 `ArrayAccess` doesn't allow indirect modification of an offset).

 * https://github.com/wp-plugins/livepress/blob/master/php/livepress-post-
 format-controller.php#L243
 * https://github.com/wp-plugins/search-by-sku-for-woocommerce/blob/master
 /wp-filters-extra.php#L40
 * https://github.com/wp-plugins/contact-form-7-add-
 confirm/blob/master/includes/controller.php#L54-L79
 * https://github.com/wp-plugins/wysija-
 newsletters/blob/master/helpers/conflicts.php#L84

 Group 4 - Plugins that directly set individual callbacks, instead of using
 `add_action()` / `add_filter()` (same technical limitation as Group 3).

 * https://github.com/wp-plugins/addme/blob/master/adder.php#L46
 * https://github.com/wp-plugins/ram108-typo/blob/master/plugin.php#L42
 * https://github.com/wp-plugins/jetpack/blob/master/class.json-api-
 endpoints.php#L1398

 Nine examples out of 40K+ plugins, and all of them could be ''easily''
 fixed. As much as I wish there were zero compatibility issues, I think
 this is more than reasonable.

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


More information about the wp-trac mailing list