[wp-trac] [WordPress Trac] #33144: remove_filter's cleanup causes do_action to skip entire next priority block.

WordPress Trac noreply at wordpress.org
Mon Jul 27 16:28:49 UTC 2015


#33144: remove_filter's cleanup causes do_action to skip entire next priority
block.
--------------------------+-----------------------------
 Reporter:  dougwollison  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Plugins       |    Version:  3.0
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I have some plugins adding actions to save_post, one at priority 15, the
 other at priority 999.

 The callback run at priority 15 starts off by removing itself before
 running since it ends up calling wp_update_post and of course needs to
 prevent an infinite loop.

 However, when it's the only callback registered to that block,
 remove_filter will attempt to do some cleanup and unset that entry of the
 array since it's empty. This seems to cause the internal pointer within
 $wp_filter[save_post] to silently advance to the next block and then skip
 that via the next() call that controls the while loop.

 Now, if the original callback adds itself back, everything's fine, but the
 code for said plugin has it call remove_action before proceeding with the
 checks for wether or not it should run at all, and so never adds itself
 back.

 This is arguably the fault of the plugin and not the core, but I think
 that cleanup line should be removed to prevent bugs like this. Otherwise
 my only option without editing the plugin code is to add a throwaway hook
 at a priority between the first one and the second, so that it get's
 skipped and not the one that's needed.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33144>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list