You are here

function _prod_check_module_list in Production check & Production monitor 6

Same name and namespace in other branches
  1. 7 prod_check.module \_prod_check_module_list()

File

./prod_check.module, line 1939

Code

function _prod_check_module_list($caller = 'internal') {
  global $base_url;
  $check = array();
  $now = time();
  $last = variable_get('prod_check_module_list_lastrun', 0);

  // The if() is split up this way for full perfomance: we only run once a week,
  // so on 6 out of 7 days, we won't pass the first if statement.
  // First check if we are scheduled to run this day of the week. See
  // prod_check_flush_caches() for the -1 case.
  if (variable_get('prod_check_module_list_day', 0) == date('w', $now) || $last == -1) {

    // First check if we already ran today.
    if (date('Ymd', $last) != date('Ymd', $now)) {
      $time = explode(':', variable_get('prod_check_module_list_time', '03:00'));

      // Only run if we are spot on, or past the scheduled point. This CAN cause
      // a run hours after the scheduled time, all depending on the cron setup
      // on the prod_monitor site!
      if (date('H', $now) >= $time[0] && date('i', $now) >= $time[1]) {
        module_load_include('inc', 'prod_check', 'includes/prod_check.update');

        // PANIC! We don't cache this! Should we!? The core update module does
        // (for one hour) but this function here ONLY gets called ONCE a week at
        // a very specific given time. Feel free to comment.
        $projects = array();
        _prod_check_process_info_list($projects, module_rebuild_cache(), 'module');
        _prod_check_process_info_list($projects, system_theme_data(), 'theme');

        // Allow other modules to alter projects before fetching and comparing.
        drupal_alter('update_projects', $projects);
        $check['prod_check_module_list']['projects'] = $projects;
        $check['prod_check_module_list']['site_key'] = md5($base_url . drupal_get_private_key());
        $check['prod_check_module_list']['last_update'] = $now;

        // Remember when we ran last.
        variable_set('prod_check_module_list_lastrun', $now);
      }
    }
  }
  return prod_check_execute_check($check, $caller, 'prod_mon');
}