function system_confirm_db_updates_form_submit

7.x system.module system_confirm_db_updates_form_submit($form, $form_state)
6.x system.module system_confirm_db_updates_form_submit($form, $form_state)
4.x system.module system_confirm_db_updates_form_submit($form, $form_state)
5.x system.module system_confirm_db_updates_form_submit($form, $form_state)

Perform the actual hook_update calls here, send the user to a completed page.

_state

Parameters

unknown_type $form:

1 call to system_confirm_db_updates_form_submit()

File

modules/system/system.module, line 791

Code

function system_confirm_db_updates_form_submit($form, $form_state) {

  // Since this could take a little while, let's use the batch system.
  $modules = array();



  // We need to find modules whose schema in their .info file
  // is different than what's in the database.

  $module_dirs = array();
  $module_dirs [] = array("start" => "modules", "type" => t("Core"));
  $module_dirs [] = array("start" => "custom/modules", "type" => t("Custom"));

  // We will also add any directories which begin with an underscore in the custom/modules directory.
  // For example:   custom/modules/_contrib
  // Let's find such directories now.
  $dir_files = scandir("custom/modules");
  foreach ($dir_files as $file) {
    if ($file == '.' || $file == '..') {
      continue;
    }
    if (substr($file, 0, 1) == '_' && is_dir("custom/modules/$file")) {
      $module_dirs [] = array("start" => "custom/modules/$file", "type" => t("Custom/$file"));
    }
  }



  foreach ($module_dirs as $module_dir) {
    $start_dir = $module_dir ["start"];

    if ($dh = opendir($start_dir)) {
      while ($file = readdir($dh)) {
        if ($file == "." || $file == "..") {
          continue;
        }

        if (is_dir($start_dir . "/" . $file)) {

          // Okay, now look inside and see if there is a .info file.
          if (file_exists("$start_dir/$file/$file.info")) {
            $module = $file;
            $info_contents = file_get_contents("$start_dir/$file/$file.info");


            // From the info_contents variable, split up and place into an array.
            $info_details_array = array();
            $lines = explode("\n", $info_contents);
            foreach ($lines as $line) {
              if (trim($line) == "") {
                continue;
              }
              $temp = explode("=", trim($line));
              $info_details_array [trim($temp [0])] = trim(substr($line, strlen($temp [0]) + 1));
            }


            $path = "$start_dir/$file";

            $res = db_query("SELECT * FROM modules WHERE path = ? ", $path);
            $cur = db_fetch_array($res);
            $info_details_array ["enabled"] = intval($cur ["enabled"]);

            // Does this module need to run db updates?
            if (@$cur ["enabled"] == 1 && @intval($cur ["schema"]) != @intval($info_details_array ["schema"]) && @$info_details_array ["schema"] != "") {

              // Add to our list of modules to run in our batch operations.

              $modules [] = array(
                'module' => $module,
                'path' => $path,
                'cur_schema' => intval($cur ['schema']),
                'schema' => intval($info_details_array ['schema']),
              );



            } // if enabled & schema != db schema  

          } // if fileexists
        }
        //if isdir(file)
      }
      // while file = readdir()
    } // if opendir
  } // foreach module dirs as module_dir  

  // Clear our cache
  //fp_clear_cache();

  //fp_goto("admin/completed-db-updates");





  // Okay, set up the batch....
  $batch = array(
    "operation" => array("system_perform_db_updates_perform_batch_operation", array($modules)),
    "title" => t("Performing Database Updates"),
    "progress_message" => "Processing @current of @total...",
    "display_percent" => TRUE,
  );

  $batch ["finished_callback"] = array("system_finished_db_updates_finished");


  watchdog("admin", "Ran DB updates for modules");


  // Set the batch...
  batch_set($batch);


}