function ultimate_cron_exit in Ultimate Cron 7.2
Implements hook_exit().
File
- ./
ultimate_cron.poorman.inc, line 92 - Poormans cron functions.
Code
function ultimate_cron_exit($dest = NULL) {
// No need for poorman until site is installed.
if (variable_get('install_task') != 'done') {
return;
}
// Don't attempt poormans stuff until fully bootstrapped.
if (drupal_bootstrap() < DRUPAL_BOOTSTRAP_FULL) {
return;
}
// We're picky about when we run poormans cron, because
// we may want to flush the output buffer.
if (!ultimate_cron_poorman_capable()) {
return;
}
$poorman = _ultimate_cron_plugin_load('settings', 'poorman');
if (!$poorman) {
return;
}
$settings = $poorman
->getDefaultSettings();
if (!$settings['launcher']) {
return;
}
$launcher = _ultimate_cron_plugin_load('launcher', $settings['launcher']);
if (!$launcher) {
watchdog('ultimate_cron', 'Invalid poormans cron launcher: @name', array(
'@name' => $settings['launcher'],
), WATCHDOG_ERROR);
return;
}
if ($settings['early_page_flush']) {
// Poormans cron needs to be the last that runs.
// Run remaining exit hooks, and shutdown like core does.
$modules = module_implements('exit');
do {
$module = array_shift($modules);
} while ($modules && $module !== 'ultimate_cron');
foreach ($modules as $module) {
module_invoke($module, 'exit', $dest);
}
// Commit the user session, if needed.
drupal_session_commit();
if (variable_get('cache', 0) && ($cache = drupal_page_set_cache())) {
drupal_serve_page_from_cache($cache);
}
_registry_check_code(REGISTRY_WRITE_LOOKUP_CACHE);
drupal_cache_system_paths();
module_implements_write_cache();
_ultimate_cron_launch_poorman($launcher);
exit;
}
else {
// Wait until the very end before running cron.
register_shutdown_function('_ultimate_cron_launch_poorman', $launcher, 3);
}
}