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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | elysia_cron-incompability-with-custom-drush-cron-executions-2829224-2-7.x.patch | 1.51 KB | spleshka |
Comments
Comment #2
spleshkaSubmitting the proposed the patch.
Comment #3
kala4ekComment #6
kala4ekGood catch, thanks for the patch.
By mistake made the first commit without your authorship :)
Comment #7
spleshkaThank you Dmitry for very fast turnaround :)