diff --git a/includes/update.inc b/includes/update.inc index 8ab682faa5c..3c8e051c274 100644 --- a/includes/update.inc +++ b/includes/update.inc @@ -199,7 +199,11 @@ function update_prepare_d7_bootstrap() { // Set a valid timezone for 6 -> 7 upgrade process. drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); - if (is_numeric(variable_get('date_default_timezone', 0))) { + $timezone_offset = variable_get('date_default_timezone', 0); + if (is_numeric($timezone_offset)) { + // Save the original offset. + variable_set('date_temporary_timezone', $timezone_offset); + // Set the timezone for this request only. $GLOBALS['conf']['date_default_timezone'] = 'UTC'; } } diff --git a/modules/system/system.install b/modules/system/system.install index 06fb1009fa8..654ca4ac7ac 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -1863,11 +1863,22 @@ function system_update_7013() { // schema found. } } + + // Check to see if timezone was overriden in update_prepare_d7_bootstrap(). + $offset = variable_get('date_temporary_timezone'); + // If not, use the default. + if (!isset($offset)) { + $offset = variable_get('date_default_timezone', 0); + } + // If the previous default time zone was a non-zero offset, guess the site's // intended time zone based on that offset and the server's daylight saving // time status. - if (!$timezone && ($offset = variable_get('date_default_timezone', 0)) && ($timezone_name = timezone_name_from_abbr('', intval($offset), date('I'))) && isset($timezones[$timezone_name])) { - $timezone = $timezone_name; + if (!$timezone && $offset) { + $timezone_name = timezone_name_from_abbr('', intval($offset), date('I')); + if ($timezone_name && isset($timezones[$timezone_name])) { + $timezone = $timezone_name; + } } // Otherwise, the default time zone offset was zero, which is UTC. if (!$timezone) { @@ -1875,6 +1886,8 @@ function system_update_7013() { } variable_set('date_default_timezone', $timezone); drupal_set_message('The default time zone has been set to ' . check_plain($timezone) . '. Check the ' . l('date and time configuration page', 'admin/config/regional/settings') . ' to configure it correctly.', 'warning'); + // Remove temporary override. + variable_del('date_temporary_timezone'); } /**