Problem/Motivation

A very interesting issue related to cron execution via custom drush command was found. One of our client hosts on Pantheon. Every hour for every working environment Pantheon internally invokes drush pantheon_cron 3600 command. In the nutshell it is a simple semaphore ("do not run cron if if was executed within last 3600 seconds") + normal cron execution which triggers drupal_cron_run() and goes ahead as usually.

What we've found in the code is that cron execution goes to Elysia cron's implementation of hook_cron() elysia_cron_cron() and then gets rerouted to a specific function elysia_cron_drush_invoke() which is designed to handle all incoming drush cron commands. So far so good.

When it gets to elysia_cron_drush_invoke() what happens is the function eats the first argument of the drush execution (remained arguments are pantheon_cron 3600). Then it finally passes remained arguments to drush_elysia_cron_run_wrapper(), which in fact expects the first param to be the desired operation (run, list, enable, disable), but it gets invalid operation instead and eventually falls into a fallback behavior. No cron execution happens.

Proposed resolution

The proposed solution is to validate the passing operation from drush command before it gets to the final drush cron handler and always assume "run" operation if it's invalid.

Remaining tasks

Review needed

User interface changes

None

API changes

From now on all incorrect operation names from drush cron command will trigger cron instead of falling with fallback. Example: drush cron list123 will trigger cron.

Comments

Spleshka created an issue. See original summary.

spleshka’s picture

Title: Incompatibility with custom cron execution commands » Incompatibility with cron executions via custom drush commands
Status: Active » Needs review
StatusFileSize
new1.51 KB

Submitting the proposed the patch.

kala4ek’s picture

Assigned: Unassigned » kala4ek

  • kala4ek committed 3a4a61f on 7.x-2.x
    Issue #2829224 by Spleshka, kala4ek: Incompatibility with cron...

  • kala4ek committed 85a2aa5 on 7.x-2.x authored by Spleshka
    Issue #2829224 by Spleshka, kala4ek: Incompatibility with cron...
kala4ek’s picture

Assigned: kala4ek » Unassigned
Status: Needs review » Fixed

Good catch, thanks for the patch.
By mistake made the first commit without your authorship :)

spleshka’s picture

Thank you Dmitry for very fast turnaround :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.