Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Consider the following scenario
- Navigate to cron settings (/admin/config/system/cron)
- Change "Run cron every" to "Never"
- Click "Save configuration"
- Cron runs!
I can see why this would be. it's reasonable to assume that someone altering cron settings might want to immediately run it. But it's counterintuitive for cron to run because you told it not to. What if I have a very good reason that I want to prevent cron from running?
Solutions?
- Leave as-is.
Changing this would cause more harm than good because most people want cron to run in this case. I disagree, but I'm willing to consider it - Don't run cron automatically after updating cron configuration
That's what the separate "Run cron" button is for! - Code an exception for when the user selects never run cron
This would probably be even more unexpected than the current situation, but I included it for completeness. - Add a "Run cron after saving" checkbox
Clunky name aside, this is far more predictable than #3, but probably overkill.
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff.txt | 1.02 KB | amateescu |
#7 | 2903183-7.patch | 2.91 KB | amateescu |
#3 | 2903183.patch | 2.94 KB | amateescu |
#3 | 2903183-test-only.patch | 1.27 KB | amateescu |
Comments
Comment #2
jwkovell CreditAttribution: jwkovell commentedComment #3
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedI think that the fact that cron runs when saving the configuration form is totally unexpected and it's simply a byproduct of the fact that the cron confguration form has only one submit handler, even though it has two separate submit buttons.
So option 2. is definitely the one to choose :) Here's a patch with tests as well.
Comment #5
dawehnerGreat patch!
Aren't the sleep statements in the original test just there due to the automated cron, but we don't care about that here? I guess there is a good explanation for those sleep calls
Comment #6
jwkovell CreditAttribution: jwkovell commentedThe patch worked for me, amateescu. Thank you so much!
Comment #7
amateescu CreditAttribution: amateescu for Pfizer, Inc. commented@dawehner, I guess I'm just used to add
sleep()
calls whenever I deal with cron, but you're right, they're not really necessary.@jkovell, I'm glad I could help :)
Comment #8
dawehner@amateescu
Don't get me wrong, I love taking a nap :)
Comment #11
catchCommitted/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!