You are here

function _prod_check_module_list in Production check & Production monitor 7

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

File

./prod_check.module, line 2024

Code

function _prod_check_module_list($caller = 'internal') {
  global $base_url;
  $check = array();
  $now = REQUEST_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();

        // Process enabled modules and themes.
        _prod_check_process_info_list($projects, system_rebuild_module_data(), 'module', TRUE);
        _prod_check_process_info_list($projects, system_rebuild_theme_data(), 'theme', TRUE);

        // Process disabled modules and themes.
        _prod_check_process_info_list($projects, system_rebuild_module_data(), 'module', FALSE);
        _prod_check_process_info_list($projects, system_rebuild_theme_data(), 'theme', FALSE);

        // 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'] = drupal_hmac_base64($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');
}