function system_perform_db_updates_perform_batch_operation

6.x system.module system_perform_db_updates_perform_batch_operation(&$batch, $modules)

Performs db updates ONE module at a time.

1 call to system_perform_db_updates_perform_batch_operation()

File

modules/system/system.module, line 906

Code

function system_perform_db_updates_perform_batch_operation(&$batch, $modules) { // if this is our first time through, let's init our values.

  if (!isset($batch ["results"]["total"])) {
    // Our first time through.  Let's start up.
    $batch ["results"]["total"] = count($modules);
    $batch ["results"]["current"] = 0;
    $batch ["results"]["finished"] = FALSE;
  }


  $t = $batch ["results"]["current"];


  $module = $modules [$t]['module'];
  $path = $modules [$t]['path'];
  $cur_schema = $modules [$t]['cur_schema'];
  $schema = $modules [$t]['schema'];

  // If the module has a .install file, begin by including it.
  if (include_module_install($module, $path)) {

    // Include the original module file first.
    include_module($module, TRUE, $path);

    // Now, we can call hook_update, if it exists.
    if (function_exists($module . '_update')) {
      call_user_func_array($module . '_update', array($cur_schema, $schema));
    }

  }

  // Okay, update the modules table for this module, and set schema to correct version.
  $res = db_query("UPDATE modules 
                    SET `schema` = '?'
                    WHERE path = '?' LIMIT 1 ", $schema, $path);


  fp_add_message(t("The module %module has run its DB updates.", array("%module" => $module)));


  // Update our values.
  $batch ["results"]["current"] = $t + 1; // go to next one.


  // Have we finished?
  if (intval($batch ["results"]["current"]) >= intval($batch ["results"]["total"])) {

    $batch ["results"]["finished"] = TRUE;
  }




}