Scheduled tasks don’t run when using Cavalcade instead of WP’s pseudo-cron
-
When using Cavalcade https://github.com/humanmade/Cavalcade to manage scheduled tasks, broken-link-checker’s scheduled tasks never run properly. The reason is that BLC prevents its core libraries from loading unless
is_admin() || defined( 'DOING_CRON' )
: https://plugins.trac.www.ads-software.com/browser/broken-link-checker/tags/1.11.21/core/init.php?marks=291,294#L286In the case of Cavalcade, scheduled tasks by a system daemon via WP-CLI:
$ wp cavalcade job run 12345
Cavalcade attempts to set the
DOING_CRON
constant: https://github.com/humanmade/Cavalcade/blob/87ff25e5f6a99b7d7c6626f966adceb086186c73/inc/class-command.php#L33 But, because of the details of how Cavalcade and WP-CLI work together (Cavalcade runs as an mu-plugin, and its CLI command is loaded only after WP-CLI runs its own bootstrap of WordPress), thisDOING_CRON
definition happens *after* broken-link-checker has decided not to load thecore.php
library. To put the same point another way, the linked line ininit.php
runs before Cavalcade setsDOING_CRON
, socore.php
is never loaded.A simple solution is to load
core.php
whenWP_CLI
is defined:if?(?is_admin()?||?defined(?'DOING_CRON'?)?|| defined( 'WP_CLI' ) )?{
Thanks for considering this change.
- The topic ‘Scheduled tasks don’t run when using Cavalcade instead of WP’s pseudo-cron’ is closed to new replies.