Opened 9 years ago
Closed 9 years ago
#33144 closed defect (bug) (duplicate)
remove_filter's cleanup causes do_action to skip entire next priority block.
Reported by: | dougwollison | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Plugins | Keywords: | |
Focuses: | Cc: |
Description
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.
Duplicate of #9968 and #21169.