Automattic / WP-Cron-Control

This plugin allows you to take control over the execution of cron jobs.
20 stars 7 forks source link

Plugin shouldn't set `DOING_CRON` for all non-cron requests #4

Open ethitter opened 8 years ago

ethitter commented 8 years ago

By setting DOING_CRON on all non-cron requests, any functionality that blocks its execution by checking that constant is automatically and always blocked.

Temporarily fixed by fcf1740, but we need to consider other ways of blocking cron requests not originating from this plugin.

joshbetz commented 8 years ago

Thank you, I forgot to open this issue when I pushed the temporary fix.

nextend commented 7 years ago

This fix should be pushed as a new version to Wordpress.org

ethitter commented 7 years ago

Before a new release is made, a proper fix for this issue is needed. The temporary fix from fcf1740 isn't sufficient, in my opinion.

nextend commented 7 years ago

Does anyone know why does that two lines there? Defining DOING_CRON constant when it is NOT a cron call does not make sense. I think the fix is fine.

ethitter commented 7 years ago

Does anyone know why does that two lines there? Defining DOING_CRON constant when it is NOT a cron call does not make sense.

It's a legacy of how the code that led to this plugin stopped subsequent requests from triggering cron, either by requesting the endpoint, or calling spawn_cron(). There are other ways of handling this now, but those didn't exist when the define was initially added.

The fix from fcf1740 is not sufficient as there's currently nothing reliably stopping two cron requests from running in parallel. The transient lock is insufficient, but this plugin's successor, Cron Control, provides guidance on how to better handle this.