$default) { $start[$module] = $update; break; } } // 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 = str_replace(array("\n", '*', '/'), '', $func->getDocComment()); } if (empty($description)) { $description = dt('description not available'); } $pending[$module][] = array("$update - ". trim($description)); $has_updates = TRUE; } } } } // Print a list of pending updates for this module and get confirmation. if ($has_updates) { drush_print(dt('The following updates are pending:')); drush_print(); foreach ($pending as $module => $updates) { if (sizeof($updates)) { array_unshift($updates, array($module . ' module')); drush_print_table($updates, TRUE); drush_print(); } } if (!drush_confirm(dt('Do you wish to run all pending updates?'))) { return drush_user_abort(); } $update_results = array(); foreach ($start as $module => $version) { drupal_set_installed_schema_version($module, $version - 1); $updates = drupal_get_schema_versions($module); $max_version = max($updates); if ($version <= $max_version) { drush_log(dt('Updating module @module from schema version @start to schema version @max', array('@module' => $module, '@start' => $version - 1, '@max' => $max_version))); foreach ($updates as $update) { $finished = FALSE; if ($update >= $version) { while (!$finished) { // do update $ret = module_invoke($module, 'update_' . $update); _drush_log_update_sql($ret); $finished = 1; if (isset($ret['#finished'])) { $finished = $ret['#finished']; unset($ret['#finished']); } } drupal_set_installed_schema_version($module, $update); } } } else { drush_log(dt('No database updates for @module module', array('@module' => $module)), 'success'); } } } else { drush_log(dt("No database updates required"), 'success'); } }