function elysia_cron_prepare_run in Elysia Cron 6.2
Same name and namespace in other branches
- 7.2 elysia_cron.module \elysia_cron_prepare_run()
Prepare system for a cron execution
This should be called at the start of a cron execution: prepare_run lock_env ... look for channel/jobs ready for execution and change internal states ... unlock_env before_execution .. execute channel/jobs .. after_execution unprepare_run
3 calls to elysia_cron_prepare_run()
- elysia_cron_run in ./
elysia_cron.module - Public function to invoke a complete cron_run
- elysia_cron_run_channel in ./
elysia_cron.module - Public function to execute all jobs in a channel
- elysia_cron_unprepare_run in ./
elysia_cron.module - Call this after a cron execution, prepared with elysia_cron_prepare_run()
File
- ./
elysia_cron.module, line 947
Code
function elysia_cron_prepare_run($manual_run, $start = true) {
static $original_user;
if ($start) {
// Allow execution to continue even if the request gets canceled.
@ignore_user_abort(true);
// Try to allocate enough time to run all the hook_cron implementations.
if (!ini_get('safe_mode')) {
set_time_limit(variable_get('elysia_cron_time_limit', 240));
}
// Prevent session information from being saved while cron is running.
drupal_save_session(FALSE);
// Force the current user to anonymous to ensure consistent permissions on
// cron runs (only if run by interface)
if ($manual_run) {
$original_user = $GLOBALS['user'];
$GLOBALS['user'] = drupal_anonymous_user();
}
}
else {
if ($manual_run) {
// Restore the user.
$GLOBALS['user'] = $original_user;
/*if (EC_DRUPAL_VERSION >= 7) {
drupal_save_session(TRUE);
}*/
}
}
}