function updatedb_status

8.0.x update_6.inc updatedb_status()
8.0.x update.inc updatedb_status()
8.0.x update_7.inc updatedb_status()
6.x update_6.inc updatedb_status()
6.x update_7.inc updatedb_status()
7.x update_6.inc updatedb_status()
7.x update.inc updatedb_status()
7.x update_7.inc updatedb_status()
master update_7.inc updatedb_status()
master update.inc updatedb_status()

Return a 2 item array with

  • an array where each item is a 3 item associative array describing a pending update.
  • an array listing the first update to run, keyed by module.
3 calls to updatedb_status()
drush_core_updatedb_status in commands/core/core.drush.inc
Command handler. List pending DB updates.
update_main in commands/core/drupal/update_6.inc
update_main in commands/core/drupal/update_7.inc

File

commands/core/drupal/update_6.inc, line 471
Update.php for provisioned sites. This file is a derivative of the standard drupal update.php, which has been modified to allow being run from the command line.

Code

function updatedb_status() {
  $return = array();

  $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
  foreach ($modules as $module => $schema_version) {
    $updates = drupal_get_schema_versions($module);
    // Skip incompatible module updates completely, otherwise test schema versions.
    if (!update_check_incompatibility($module) && $updates !== FALSE && $schema_version >= 0) {
      // module_invoke returns NULL for nonexisting hooks, so if no updates
      // are removed, it will == 0.
      $last_removed = module_invoke($module, 'update_last_removed');
      if ($schema_version < $last_removed) {
        drush_set_error('PROVISION_DRUPAL_UPDATE_FAILED', dt($module . ' module can not be updated. Its schema version is ' . $schema_version . '. Updates up to and including ' . $last_removed . ' have been removed in this release. In order to update ' . $module . ' module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.'));
        continue;
      }

      $updates = drupal_map_assoc($updates);

      // Record the starting update number for each module.
      foreach (array_keys($updates) as $update) {
        if ($update > $schema_version) {
          $start[$module] = $update;
          break;
        }
      }
      if (isset($start['system'])) {
        // Ensure system module's updates run first.
        $start = array('system' => $start['system']) + $start;
      }

      // Record any pending updates. Used for confirmation prompt.
      foreach (array_keys($updates) as $update) {
        if ($update > $schema_version) {
          if (class_exists('ReflectionFunction')) {
            // The description for an update comes from its Doxygen.
            $func = new ReflectionFunction($module . '_update_' . $update);
            $description = trim(str_replace(array("\n", '*', '/'), '', $func->getDocComment()));
          }
          if (empty($description)) {
            $description = dt('description not available');
          }

          $return[] = array(
            'module' => ucfirst($module),
            'update_id' => $update,
            'description' => $description,
          );
        }
      }
    }
  }

  return array($return, $start);
}