function update_script_selection_form() { $form = array(); $count = 0; $form['start'] = array('#tree' => TRUE, '#type' => 'fieldset', '#collapsed' => TRUE, '#collapsible' => TRUE); // Ensure system.module's updates appear first $form['start']['system'] = array(); $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE); foreach ($modules as $module => $schema_version) { $pending = array(); $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) { $form['start'][$module] = array('#title' => $module, '#item' => '<em>' . $module . '</em> 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 <em>' . $module . '</em> module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.', '#prefix' => '<div class="warning">', '#suffix' => '</div>'); continue; } $updates = drupal_map_assoc($updates); foreach (array_keys($updates) as $update) { if ($update > $schema_version) { // The description for an update comes from its Doxygen. $func = new ReflectionFunction($module . '_update_' . $update); $description = str_replace(array("\n", '*', '/'), '', $func->getDocComment()); $pending[] = "{$update} - {$description}"; if (!isset($default)) { $default = $update; } } } if (!empty($pending)) { if (!isset($default)) { $default = $schema_version; } $form['start'][$module] = array('#type' => 'hidden', '#value' => $default); $form['start'][$module . '_updates'] = array('#markup' => theme('item_list', $pending, $module . ' module')); } } unset($default); $count = $count + count($pending); } if (empty($count)) { drupal_set_message(t('No pending updates.')); unset($form); $form['links'] = array('#markup' => theme('item_list', update_helpful_links())); } else { $form['help'] = array('#markup' => '<p>The version of Drupal you are updating from has been automatically detected.</p>', '#weight' => -5); $form['start']['#title'] = strtr('!num pending updates', array('!num' => $count)); $form['has_js'] = array('#type' => 'hidden', '#default_value' => FALSE); $form['submit'] = array('#type' => 'submit', '#value' => 'Apply pending updates'); } return $form; }
/** * Disable anything in the {system} table that is not compatible with the * current version of Drupal core. */ function update_fix_compatibility() { $ret = array(); $incompatible = array(); $query = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')"); while ($result = db_fetch_object($query)) { if (update_check_incompatibility($result->name, $result->type)) { $incompatible[] = $result->name; } } if (!empty($incompatible)) { $ret[] = update_sql("UPDATE {system} SET status = 0 WHERE name IN ('" . implode("','", $incompatible) . "')"); } return $ret; }