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.
The cron settings at admin/config/system/cron need to be converted to use the new configuration system. There is currently only one setting to set the cron run time, so it should be super easy.
Tasks
- Create a default config file names system.cron.xml and add it to the system module.
- Convert the admin UI in system.admin.inc to read to/write from the appropriate config.
- Convert any code that currently accesses the cron variable to use the config system.
- Write an upgrade path from D7 -> D8 to migrate existing data to the new system and drop the appropriate variables.
This would be a good task for someone wanting to get up to speed on how the new config system works. Feel free to ping me on IRC if you need help.
Comment | File | Size | Author |
---|---|---|---|
#76 | drupal8.config-cron.76.patch | 10.44 KB | sun |
#72 | drupal8.config-cron.71.patch | 10.36 KB | sun |
#72 | interdiff.txt | 4.26 KB | sun |
#69 | drupal8.config-cron.69.patch | 8.2 KB | sun |
#60 | drupal8.config-cron.60.patch | 7.32 KB | sun |
Comments
Comment #1
PolFirst shot of the patch.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedthis looks good to me. the only remaining bit is the upgrade path.
Comment #4
PolUpdated patch, fix the typo (cron_max_threshold <> cron_safe_threshold)
The tests will fail because of #1324618: Implement automated config saving for simple settings forms.
Once this issue will be fixed, the test will be successful.
Comment #5
PolAdded the upgrade path in
system.install
.The upgrade path is a simple
variable_del('cron_safe_threshold');
.Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedjust setting to needs review so the bot will see it.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedok, i spent a bit more time looking at this. there are a bunch more cron_* variables to convert to the new system.
from a bit of grepping, i can see:
cron_last
cron_threshold_warning
cron_threshold_error
cron_key
there is also cron_semaphore, but i think that should go into the key/value store when that's ready.
Comment #9
wamilton CreditAttribution: wamilton commentedHere's my stab at just that. cron_last is also 'state' not 'config' just like cron_semaphore, so no changes there. Also helped out aggregator and simpletest.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commented#9 looks good. i've created a 1493098-cron branch for this code, and will probably push #9 into it if the tests come back green.
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedoh, doh. ok i'm going to look into that error.
also, wamilton, if you're at drupalcon, come find me! i'm beejeebus in #durpalcon and #drupal-contribute.
Comment #13
wamilton CreditAttribution: wamilton commentedMy bad, calling ::save() now and not trying to get the variable names from config()->get(). I guess we hardcode instead?
Comment #15
wamilton CreditAttribution: wamilton commentedHoly cow, lets get our files into the diff!
Per beejeebus, we are still trying to infer variable names from the config() active store as they really ought to be present.
@beejeebus: thanks for the help!
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedok, two things to fix here:
- we're not calling save in the test
- we're need to use the $form_state['conf'] hack in system_settings_form_submit().
hopefully this will pass.
Comment #18
Rok Žlender CreditAttribution: Rok Žlender commentedFew things in patch #17
Extra line
Is there a reason why save() is not called in system_install for setting cron_key
Attached patch fixes these two.
Comment #19
Rok Žlender CreditAttribution: Rok Žlender commentedComment #21
Rok Žlender CreditAttribution: Rok Žlender commentedNow rerolled with update hook.
Comment #22
Rok Žlender CreditAttribution: Rok Žlender commentedOk and now with added new file that is missing in my previous patches :/
Comment #23
Mark Theunissen CreditAttribution: Mark Theunissen commentedThis is my first look at the config management system.
$var_names will be empty, as there's nothing in the active store at this point. Therefore this update does nothing - it's a circular problem - this update is supposed to populate the active store but can't as it relies on the existence of the store to run. Perhaps get the names from somewhere else or hardcode them?
Rather specify the exact fields you would like to query.
Minor code style, put a space after 'foreach'
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous commentedok, this looks good to go to me.
Comment #25
Mark Theunissen CreditAttribution: Mark Theunissen commentedThe update didn't work for me when I tested it, see above.
Comment #26
Lars Toomre CreditAttribution: Lars Toomre commentedThis patch has the added issue that the variables are first deleted and then saved to new config file. The order needs to be reversed to prevent possible data loss if the write to config fails.
Comment #27
pcambraThe upgrade path is being covered in #1497132: Provide a generalised function to update variables from Drupal 7 to Drupal 8's configuration management system, setting the dependence here.
Comment #28
gddSo this needs to be rerolled to use update_variables_to_config() now that that has gotten committed.
Comment #29
pcambraRerolling it using the new update function.
Comment #31
pcambraAnother try.
Changes in here:
cron_safe_threshold
, if we're deleting the constant I think we should provide a default.Not sure what's the plan for 'state' vars such as cron_last.
Comment #32
Lars Toomre CreditAttribution: Lars Toomre commentedZero byte patch in #31.
Comment #33
pcambraOops, not sure what happened. Attaching a new one :)
Comment #34
swentel CreditAttribution: swentel commentedWhitespace
-29 days to next Drupal core point release.
Comment #35
jcisio CreditAttribution: jcisio commentedI'm trying to work on this today.
Comment #36
jcisio CreditAttribution: jcisio commentedFix a fatal error, use $config when available and do not create a new $config when not necessary (also, for the consistency).
Comment #38
jcisio CreditAttribution: jcisio commentedDon't know why some change was included in interdiff but not in the full patch.
Comment #40
jcisio CreditAttribution: jcisio commentedSpace in filename?
Comment #41
gddThis patch is missing the system.cron.xml file which provides defaults for the cron settings. This file is in earlier patches. I'm not really sure why all tests pass given this, that is something worth looking at.
Comment #42
jcisio CreditAttribution: jcisio commentedsystem.cron.xml added.
Comment #43
jcisio CreditAttribution: jcisio commentedSorry, this time it is really.
Comment #44
gddUnfortunately this now needs a reroll because system_update_8008() is already declared, so it needs to be renamed to system_update_8009(). However other than that, I've tested everything and it appears ready to go. Make that change and I'll RTBC. Thanks!
Comment #45
pcambraUpdated and back to CNR
Comment #46
gddAwesome!
Comment #47
catchSorry folks this will need a re-roll for the cron.php hunk, since that file no longer exists.
Comment #48
jcisio CreditAttribution: jcisio commentedI'm working for a patch.
Comment #49
jcisio CreditAttribution: jcisio commentedHere you are.
Comment #50
gddThanks jcisio!
Comment #51
tstoecklerSeems like the indentation is off.
I think it's weird that we're adding this code, even though system_settings_form() has not been converted yet. Maybe add a little comment about that?
Needs work for the first at least, the second is debatable I guess.
Comment #52
jcisio CreditAttribution: jcisio commentedSame patch as #49, solves two comments in #51. I just added a simple @todo, there are a few debatable points, but they could be fixed later. A more important point, which will require an update function, is how the variables are name: here in system.cron.xml they are named with cron_ prefix, but in other (e.g. search.module), the variable prefix was removed. But I think it is bikeshedding, as 51 comments and nobody points it out, so I leave it as is.
Comment #53
jcisio CreditAttribution: jcisio commentedForgot the patch.
Comment #54
tstoecklerActually, #53 is a valid point. The config keys should not be prefixed with cron.
I guess?!
Current examples in core:
http://drupalcode.org/project/drupal.git/blob/HEAD:/core/modules/system/...
http://drupalcode.org/project/drupal.git/blob/HEAD:/core/modules/block/c... (Hmm... This one uses "block_cache" as key in "block.performance")
http://drupalcode.org/project/drupal.git/blob/HEAD:/core/modules/image/c...
and friends
Comment #55
gddI would like to keep the keys the same as their respective variables in Drupal 7. I pushed the search settings patch back to needs work based on this. If we decide to change the names, we can do it in a followup patch.
Therefore I'm back to RTBC on this.
Comment #56
catchThis no longer applies after the simpletest PSR-0 conversion. Tagging novice for re-roll.
Comment #57
jcisio CreditAttribution: jcisio commentedGit detected file move and created the attached patch automatically. It should hopefully work.
Comment #58
catchComment #59
catchCommitted/pushed to 8.x, thanks all.
Comment #60
sunThanks for your hard work on this.
Re-opening due to a couple of issues though, and to align the new names with #1599554: Tutorial/guidelines for how to convert variables into configuration
This variable does not exist.
Grepping for this name did not yield any other writes than this configuration form.
Further research showed that this is completely broken and the UI exposes an entirely bogus setting currently. The relevant code logic only differs between 0 or >0, and the actual interval is not taken into account at all.
Fixing that properly is left to #1554872: "Run cron every" setting (cron_safe_threshold) is not an interval but a Boolean
For this issue, we just want to have a sane config key.
This is not used anywhere.
Comment #61
sunComment #62
catchWhat is 'web'?
Comment #64
sun"threshold.poormanscron" would be most appropriate and most understandable for long-time Drupalers ;)
For anyone else + newcomers? I've no idea! How do you call the frequency or time interval for calling a function that is called as a PHP shutdown function in order to run Drupal cron jobs, mainly via web browsers of random site visitors? :)
"threshold.web" in the sense of "the threshold/interval to execute the web-based/-triggered cron crunner" made some sense to me.
Comment #65
sunChecking the test failures, I'm fairly sure this patch will pass as-is, after #1496542: Convert site information to config system has landed.
Comment #66
tstoecklerAbove it was (sort of) discussed, that we put this there so that #1324618: Implement automated config saving for simple settings forms automatically works with this patch. I wasn't a huge advocate of putting it in, just saying it was put there for a reason.
Can you explain what the point of this is? I don't get it.
Regarding the key name, maybe "auto_run", as after that threshold cron is run "automatically" (from the viewpoint of the site administrator)?
Comment #67
tstoecklerSorry, leaving at "needs review" for now.
Comment #68
sunconfig('system.cron')->get('threshold.autorun')
makes sense to me. Wanna re-roll with that?That said, depending on its outcome, it's possible that #1554872: "Run cron every" setting (cron_safe_threshold) is not an interval but a Boolean will likely remove the 'threshold.' prefix, but that's none of our business here.
New patches will still fail as long as #1496542: Convert site information to config system did not land.
Comment #69
sunRe-rolled with adjustments against latest HEAD.
Comment #71
jcisio CreditAttribution: jcisio commentedcron_max_threshold is lost?
Comment #72
sunRegarding cron_max_threshold, see #60 - the variable is entirely obsolete.
Apparently, the Drupal installer does not install system module in the regular/proper procedure. Due to that, the system.cron:key is never actually set/updated after the Drupal installation. Attached patch additionally fixes the Drupal installer to install System module correctly.
Comment #74
sun#72: drupal8.config-cron.71.patch queued for re-testing.
Comment #76
sunRe-rolled against HEAD.
Comment #77
cosmicdreams CreditAttribution: cosmicdreams commentedgreat patch, looks like it catches everything. Only spacing issues here that I'm quibbling about. IMO it's RTBC
spacing here seems to hurt not help readibility
as well as here
Comment #78
Dries CreditAttribution: Dries commentedLooks good to me. Committed to 8.x. Thanks!
Comment #79
sun