Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.10 diff -u -r1.10 install.php --- install.php 23 Aug 2006 08:25:43 -0000 1.10 +++ install.php 23 Aug 2006 16:50:33 -0000 @@ -421,8 +421,6 @@ */ function install_complete($profile) { global $base_url; - // Store install profile for later use. - variable_set('install_profile', $profile); // Bootstrap newly installed Drupal, while preserving existing messages. $messages = $_SESSION['messages']; Index: update.php =================================================================== RCS file: /cvs/drupal/drupal/update.php,v retrieving revision 1.200 diff -u -r1.200 update.php --- update.php 18 Aug 2006 18:58:44 -0000 1.200 +++ update.php 23 Aug 2006 16:47:48 -0000 @@ -200,7 +200,7 @@ db_query('UPDATE {system} SET schema_version = 0 WHERE status = 1'); // Set schema version for core - drupal_set_installed_schema_version('system', $sql_updates[$update_start]); + drupal_set_installed_schema_version('module', 'system', $sql_updates[$update_start]); variable_del('update_start'); } } @@ -216,7 +216,7 @@ function update_fix_sessions() { $ret = array(); - if (drupal_get_installed_schema_version('system') < 130 && !variable_get('update_sessions_fixed', FALSE)) { + if (drupal_get_installed_schema_version('module', 'system') < 130 && !variable_get('update_sessions_fixed', FALSE)) { if ($GLOBALS['db_type'] == 'mysql') { db_query("ALTER TABLE {sessions} ADD cache int(11) NOT NULL default '0' AFTER timestamp"); } @@ -236,7 +236,7 @@ * when update 115 is removed. It is part of the Drupal 4.5 to 4.7 migration. */ function update_fix_watchdog_115() { - if (drupal_get_installed_schema_version('system') < 115 && !variable_get('update_watchdog_115_fixed', FALSE)) { + if (drupal_get_installed_schema_version('module', 'system') < 115 && !variable_get('update_watchdog_115_fixed', FALSE)) { if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("ALTER TABLE {watchdog} ADD severity tinyint(3) unsigned NOT NULL default '0'"); } @@ -259,7 +259,7 @@ * when update 142 is removed. It is part of the Drupal 4.6 to 4.7 migration. */ function update_fix_watchdog() { - if (drupal_get_installed_schema_version('system') < 142 && !variable_get('update_watchdog_fixed', FALSE)) { + if (drupal_get_installed_schema_version('module', 'system') < 142 && !variable_get('update_watchdog_fixed', FALSE)) { switch ($GLOBALS['db_type']) { case 'pgsql': $ret = array(); @@ -279,16 +279,25 @@ * Perform one update and store the results which will later be displayed on * the finished page. * - * @param $module - * The module whose update will be run. + * @param $type + * Type of item to be updated, e.g., 'module' or 'profile'. + * @param $name + * The item whose update will be run. * @param $number * The update number to run. - * * @return * TRUE if the update was finished. Otherwise, FALSE. */ -function update_data($module, $number) { - $ret = module_invoke($module, 'update_'. $number); +function update_data($type, $name, $number) { + switch($type) { + case 'module': + $ret = module_invoke($name, 'update_'. $number); + break; + default: + $function = $name .'_'. $type .'_update_'. $number; + $ret = function_exists($function) ? $function() : NULL; + break; + } // Assume the update finished unless the update results indicate otherwise. $finished = 1; if (isset($ret['#finished'])) { @@ -300,17 +309,20 @@ if (!isset($_SESSION['update_results'])) { $_SESSION['update_results'] = array(); } - if (!isset($_SESSION['update_results'][$module])) { - $_SESSION['update_results'][$module] = array(); + if (!isset($_SESSION['update_results'][$type])) { + $_SESSION['update_results'][$type] = array(); + } + if (!isset($_SESSION['update_results'][$type][$name])) { + $_SESSION['update_results'][$type][$name] = array(); } - if (!isset($_SESSION['update_results'][$module][$number])) { - $_SESSION['update_results'][$module][$number] = array(); + if (!isset($_SESSION['update_results'][$type][$name][$number])) { + $_SESSION['update_results'][$type][$name][$number] = array(); } - $_SESSION['update_results'][$module][$number] = array_merge($_SESSION['update_results'][$module][$number], $ret); + $_SESSION['update_results'][$type][$name][$number] = array_merge($_SESSION['update_results'][$type][$name][$number], $ret); if ($finished == 1) { // Update the installed version - drupal_set_installed_schema_version($module, $number); + drupal_set_installed_schema_version($type, $name, $number); } return $finished; @@ -338,28 +350,56 @@ '#collapsed' => TRUE, ); + $form['start']['module'] = array( + '#tree' => TRUE, + '#type' => 'fieldset', + '#title' => 'Modules', + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); + // Ensure system.module's updates appear first - $form['start']['system'] = array(); + $form['start']['module']['system'] = array(); + + $form['start']['profile'] = array( + '#tree' => TRUE, + '#type' => 'fieldset', + '#title' => 'Profiles', + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); - foreach (module_list() as $module) { - $updates = drupal_get_schema_versions($module); - if ($updates !== FALSE) { - $updates = drupal_map_assoc($updates); - $updates[] = 'No updates available'; - $default = drupal_get_installed_schema_version($module); - foreach (array_keys($updates) as $update) { - if ($update > $default) { - $default = $update; - break; + // Modules and install profiles are the two system item types that support + // updates. + foreach(array('module', 'profile') as $type) { + switch($type) { + case 'module': + $items = module_list(); + break; + case 'profile': + $items = array(drupal_get_installed_profile()); + break; + } + foreach ($items as $name) { + $updates = drupal_get_schema_versions($type, $name); + if ($updates !== FALSE) { + $updates = drupal_map_assoc($updates); + $updates[] = 'No updates available'; + $default = drupal_get_installed_schema_version($type, $name); + foreach (array_keys($updates) as $update) { + if ($update > $default) { + $default = $update; + break; + } } - } - $form['start'][$module] = array( - '#type' => 'select', - '#title' => $module . ' module', - '#default_value' => $default, - '#options' => $updates, - ); + $form['start'][$type][$name] = array( + '#type' => 'select', + '#title' => $name .' '. $type, + '#default_value' => $default, + '#options' => $updates, + ); + } } } @@ -377,14 +417,16 @@ function update_update_page() { // Set the installed version so updates start at the correct place. - foreach ($_POST['edit']['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) { - foreach ($updates as $update) { - if ($update >= $version) { - $_SESSION['update_remaining'][] = array('module' => $module, 'version' => $update); + foreach ($_POST['edit']['start'] as $type => $item) { + foreach ($item as $name => $version) { + drupal_set_installed_schema_version($type, $name, $version - 1); + $updates = drupal_get_schema_versions($type, $name); + $max_version = max($updates); + if ($version <= $max_version) { + foreach ($updates as $update) { + if ($update >= $version) { + $_SESSION['update_remaining'][] = array('type' => $type, 'name' => $name, 'version' => $update); + } } } } @@ -421,7 +463,7 @@ */ function update_do_updates() { while (($update = reset($_SESSION['update_remaining']))) { - $update_finished = update_data($update['module'], $update['version']); + $update_finished = update_data($update['type'], $update['name'], $update['version']); if ($update_finished == 1) { // Dequeue the completed update. unset($_SESSION['update_remaining'][key($_SESSION['update_remaining'])]); @@ -440,11 +482,11 @@ } // When no updates remain, clear the cache. - if (!isset($update['module'])) { + if (!isset($update['type'])) { db_query('DELETE FROM {cache}'); } - return array($percentage, isset($update['module']) ? 'Updating '. $update['module'] .' module' : 'Updating complete'); + return array($percentage, isset($update['name']) ? 'Updating '. $update['name'] .' '. $update['type'] : 'Updating complete'); } /** @@ -515,7 +557,7 @@ } else { $update = reset($_SESSION['update_remaining']); - $output = '
The update process was aborted prematurely while running update #'. $update['version'] .' in '. $update['module'] .'.module. All other errors have been logged. You may need to check the watchdog database table manually.
The update process was aborted prematurely while running update #'. $update['version'] .' in '. $update['name'] .'.'. $update['type'] .'. All other errors have been logged. You may need to check the watchdog database table manually.