diff options
author | Dries Buytaert <dries@buytaert.net> | 2006-08-09 07:42:55 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2006-08-09 07:42:55 +0000 |
commit | 37469a8df4e754327c24b3cf29b3c1e79d0caaf8 (patch) | |
tree | 11b83c7714485742a18af5584a7953d277c315df /includes | |
parent | 3c975f4bb8d3975dc73444e47d01dd98e9b2b37a (diff) | |
download | brdo-37469a8df4e754327c24b3cf29b3c1e79d0caaf8.tar.gz brdo-37469a8df4e754327c24b3cf29b3c1e79d0caaf8.tar.bz2 |
- Patch #76958 by forngren, dww et al: make it a tad easier to run cron manually.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/includes/common.inc b/includes/common.inc index 934f8a829..af3371cc2 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1539,3 +1539,34 @@ function drupal_mail($mailkey, $to, $subject, $body, $from = NULL, $headers = ar ); } } + +/** + * Executs a cron run when called + * @return + * Returns TRUE if ran successfully + */ +function drupal_cron_run() { + // If not in 'safe mode', increase the maximum execution time: + if (!ini_get('safe_mode')) { + set_time_limit(240); + } + + // Check if the last cron run completed + if (variable_get('cron_busy', FALSE)) { + watchdog('cron', t('Last cron run did not complete.'), WATCHDOG_WARNING); + } + else { + variable_set('cron_busy', TRUE); + } + + // Iterate through the modules calling their cron handlers (if any): + module_invoke_all('cron'); + + // Clean up + variable_set('cron_busy', FALSE); + variable_set('cron_last', time()); + watchdog('cron', t('Cron run completed.'), WATCHDOG_NOTICE); + + // Return TRUE so other functions can check if it did run successfully + return TRUE; +} |