function _ultimate_cron_preload_cron_data in Ultimate Cron 8
Same name and namespace in other branches
- 6 ultimate_cron.module \_ultimate_cron_preload_cron_data()
- 7 ultimate_cron.module \_ultimate_cron_preload_cron_data()
Load all cronjob settings and processes.
Return value
array Array of cronjobs and their data.
3 calls to _ultimate_cron_preload_cron_data()
- drush_ultimate_cron_cron_list in ./
ultimate_cron.drush.inc - List cron jobs.
- ultimate_cron_nagios_get_job_info in ./
ultimate_cron.nagios.inc - Get information about running jobs - currently running or failed.
- ultimate_cron_view_page in ./
ultimate_cron.admin.inc - Page overviewing cron jobs.
File
- ./
ultimate_cron.module, line 1305 - @todo Add filter on overview page. @todo Add log view (with graph). @todo Make proper markup for overview page. @todo Refactor drush stuff, too many intimate relations with Background Process @todo Refactor Cron % offset stuff. Too mixed up and…
Code
function _ultimate_cron_preload_cron_data() {
$handle_prefix = variable_get('ultimate_cron_handle_prefix', ULTIMATE_CRON_HANDLE_PREFIX);
if (module_exists('ctools')) {
ctools_include('export');
$functions = ctools_export_crud_load_all('ultimate_cron');
}
else {
$functions = db_select('ultimate_cron', 'u')
->fields('u', array(
'name',
'settings',
))
->execute()
->fetchAllAssoc('name', PDO::FETCH_ASSOC);
foreach ($functions as &$function) {
$function = (object) $function;
if (!empty($function->settings)) {
$function->settings = unserialize($function->settings);
}
}
}
$hooks = ultimate_cron_get_hooks();
if (function_exists('background_process_update_status')) {
$query = db_select('background_process', 'b')
->fields('b', array(
'handle',
'service_host',
))
->condition('handle', $handle_prefix . '%', 'LIKE');
$query
->addField('b', 'start_stamp', 'start');
$query
->addField('b', 'exec_status', 'status');
$processes = $query
->execute()
->fetchAllAssoc('handle', PDO::FETCH_ASSOC);
}
else {
$processes = db_select('background_process', 'b')
->fields('b', array(
'handle',
'service_host',
'start',
'status',
))
->condition('handle', $handle_prefix . '%', 'LIKE')
->execute()
->fetchAllAssoc('handle', PDO::FETCH_ASSOC);
}
$data = array();
foreach ($hooks as $name => $hook) {
$settings = empty($functions[$name]->settings) ? array() : $functions[$name]->settings;
$settings += $hook['settings'];
$handle = $handle_prefix . $name;
$data[$name] = array(
'settings' => $settings,
'background_process' => empty($processes[$handle]) ? NULL : (object) $processes[$handle],
);
}
return $data;
}