Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.1210 diff -u -u -r1.1210 common.inc --- includes/common.inc 22 Aug 2010 12:46:21 -0000 1.1210 +++ includes/common.inc 22 Aug 2010 15:08:15 -0000 @@ -197,20 +197,24 @@ /** * Get the name of the currently active install profile. * - * When this function is called during Drupal's initial installation process, - * the name of the profile that's about to be installed is stored in the global - * installation state. At all other times, the standard Drupal systems variable - * table contains the name of the current profile, and we can call variable_get() - * to determine what one is active. + * This value is stored in the settings.php file generated during installation. + * + * Because we need to have this information before the database connection is + * initialized, to correctly determine where to search for modules and themes, + * we can not use the variable system to store this value. + * + * If this function is called during the initial installation process, + * the global variable will be initialized to the profile requested by the user + * and then stored in the settings file for future use. * * @return $profile * The name of the install profile. */ function drupal_get_profile() { - global $install_state; + global $install_profile; - if (isset($install_state['parameters']['profile'])) { - $profile = $install_state['parameters']['profile']; + if (isset($install_profile)) { + $profile = $install_profile; } else { $profile = variable_get('install_profile', 'standard'); Index: includes/install.core.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.core.inc,v retrieving revision 1.26 diff -u -u -r1.26 install.core.inc --- includes/install.core.inc 30 Jul 2010 01:59:14 -0000 1.26 +++ includes/install.core.inc 22 Aug 2010 15:08:15 -0000 @@ -1014,6 +1014,11 @@ 'value' => drupal_hash_base64(drupal_random_bytes(55)), 'required' => TRUE, ); + $settings['install_profile'] = array( + 'value' => $install_state['parameters']['profile'], + 'required' => TRUE + ); + drupal_rewrite_settings($settings); // Indicate that the settings file has been verified, and check the database // for the last completed task, now that we have a valid connection. This @@ -1492,9 +1497,6 @@ // Register actions declared by any modules. actions_synchronize(); - // Remember the profile which was used. - variable_set('install_profile', drupal_get_profile()); - // Install profiles are always loaded last db_update('system') ->fields(array('weight' => 1000)) Index: includes/update.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/update.inc,v retrieving revision 1.64 diff -u -u -r1.64 update.inc --- includes/update.inc 17 Jul 2010 19:44:06 -0000 1.64 +++ includes/update.inc 22 Aug 2010 15:08:15 -0000 @@ -354,12 +354,30 @@ // Rewrite the settings.php file if necessary, see // update_prepare_d7_bootstrap(). - global $update_rewrite_settings, $db_url, $db_prefix; + global $update_rewrite_settings, $db_url, $db_prefix, $install_profile; if (!empty($update_rewrite_settings)) { $databases = update_parse_db_url($db_url, $db_prefix); $salt = drupal_hash_base64(drupal_random_bytes(55)); - file_put_contents(conf_path() . '/settings.php', "\n" . '$databases = ' . var_export($databases, TRUE) . ";\n\$drupal_hash_salt = '$salt';", FILE_APPEND); + + // The install profile was renamed from 'default' to 'standard'. + // This change was originally handled in system_update_7049(), + // but because we no longer use a variable to store the profile name, + // it is no longer necessary. + $profile = variable_get('install_profile', 'standard'); + if ($profile == 'default') { + $profile = 'standard'; + } + + file_put_contents(conf_path() . '/settings.php', "\n" . '$databases = ' . var_export($databases, TRUE) . ";\n\$drupal_hash_salt = '$salt';\n" . '$install_profile = ' . var_export($profile, TRUE) . ';', FILE_APPEND); + + // We modify the $install_profile global, so that future calls to drupal_get_profile() will return the correct value, + // because the settings.php file has already been loaded at this point. + $install_profile = $profile; + + // Remove the unnecessary variable. + variable_del('install_profile'); } + if (drupal_get_installed_schema_version('system') < 7000 && !variable_get('update_d7_requirements', FALSE)) { // Change 6.x system table field values to 7.x equivalent. // Change field values. Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.225 diff -u -u -r1.225 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 19 Jul 2010 21:54:46 -0000 1.225 +++ modules/simpletest/drupal_web_test_case.php 22 Aug 2010 15:08:15 -0000 @@ -565,7 +565,7 @@ } protected function setUp() { - global $conf; + global $conf, $install_profile; // Store necessary current values before switching to the test environment. $this->originalFileDirectory = file_directory_path(); @@ -1123,7 +1123,7 @@ * either a single array or a variable number of string arguments. */ protected function setUp() { - global $user, $language, $conf; + global $user, $language, $conf, $install_profile; // Generate a temporary prefixed database to ensure that tests have a clean starting point. $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000); @@ -1194,7 +1194,7 @@ variable_set('file_temporary_path', $temp_files_directory); // Include the default profile. - variable_set('install_profile', 'standard'); + $install_profile = 'standard'; $profile_details = install_profile_info('standard', 'en'); // Install the modules specified by the default profile. Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.498 diff -u -u -r1.498 system.install --- modules/system/system.install 22 Aug 2010 14:55:29 -0000 1.498 +++ modules/system/system.install 22 Aug 2010 15:08:16 -0000 @@ -2435,9 +2435,10 @@ * Rename 'Default' profile to 'Standard.' */ function system_update_7049() { - if (variable_get('install_profile', 'standard') == 'default') { - variable_set('install_profile', 'standard'); - } + // This change is now handled by update_fix_d7_requirements(). + // We no longer store the install profile in a variable, but rather + // keep it in the settings.php, as it may need to be accessed + // before the database connection has been made. } /** Index: sites/default/default.settings.php =================================================================== RCS file: /cvs/drupal/drupal/sites/default/default.settings.php,v retrieving revision 1.50 diff -u -u -r1.50 default.settings.php --- sites/default/default.settings.php 8 Aug 2010 19:35:49 -0000 1.50 +++ sites/default/default.settings.php 22 Aug 2010 15:08:16 -0000 @@ -213,6 +213,15 @@ $drupal_hash_salt = ''; /** + * Install profile: + * + * Drupal can be installed with one of several install profiles, which + * will provide some initial configuration and an additional location for + * modules and themes to be loaded from. + */ + $install_profile = ''; + +/** * Base URL (optional). * * If Drupal is generating incorrect URLs on your site, which could