Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cron_example/cron_example.install
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
function cron_example_install() {
$config = config('cron_example.settings');
$config->set('cron_example_next_execution', time());
$config->set('cron_example_interval', 60*60);
$config->save();
}
8 changes: 4 additions & 4 deletions cron_example/cron_example.module
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function cron_example_form($form, &$form_state) {
*/
function cron_example_form_cron_run_submit($form, &$form_state) {
if (!empty($form_state['values']['cron_reset'])) {
config_set('cron_example.settings', 'cron_example_next_execution', 0);
state_set('cron_example_next_execution', 0);
}

// We don't usually use globals in this way. This is used here only to
Expand Down Expand Up @@ -185,15 +185,15 @@ function cron_example_cron() {
$interval = config_get('cron_example.settings', 'cron_example_interval');
// We usually don't want to act every time cron runs (which could be every
// minute) so keep a time for the next run in a variable.
if (time() >= config_get('cron_example.settings', 'cron_example_next_execution')) {
if (time() >= state_get('cron_example_next_execution', 0)) {
// This is a silly example of a cron job.
// It just makes it obvious that the job has run without
// making any changes to your database.
watchdog('cron_example', 'cron_example ran');
if (!empty($GLOBALS['cron_example_show_status_message'])) {
backdrop_set_message(t('cron_example executed at %time', array('%time' => cron_example_date_iso8601(time(0)))));
}
config_set('cron_example.settings', 'cron_example_next_execution', time() + $interval);
state_set('cron_example_next_execution', time() + $interval);
}
}

Expand Down Expand Up @@ -276,7 +276,7 @@ function cron_example_queue_report_work($worker, $item) {
function cron_example_date_iso8601($date) {
// The DATE_ISO8601 constant cannot be used here because it does not match
// date('c') and produces invalid RDF markup.
return date('c', $date);
return date('c', $date);
}
/**
* @} End of "defgroup cron_example".
Expand Down
2 changes: 1 addition & 1 deletion cron_example/cron_example.test
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CronExampleTestCase extends BackdropWebTestCase {
public function testCronExampleBasic() {
// Pretend that cron has never been run (even though simpletest seems to
// run it once...)
config_set('cron_example.settings', 'cron_example_next_execution', 0);
state_set('cron_example_next_execution', 0);
$this->backdropGet('examples/cron_example');

// Initial run should cause cron_example_cron() to fire.
Expand Down