Commit 3e914018 authored by Dries's avatar Dries

- Patch #880278 by RoboPhred: cleanup _locale_import_read_po().

parent 570dcc57
......@@ -1136,6 +1136,7 @@ function drupal_serve_page_from_cache(stdClass $cache) {
$etag = '"' . $cache->created . '-' . intval($return_compressed) . '"';
header('Etag: ' . $etag);
drupal_set_configured_timezone();
// See if the client has provided the required HTTP headers.
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
......@@ -1943,9 +1944,26 @@ function drupal_get_user_timezone() {
return $user->timezone;
}
else {
// Ignore PHP strict notice if time zone has not yet been set in the php.ini
// configuration.
return variable_get('date_default_timezone', @date_default_timezone_get());
// Note that is no site-wide timezone is set, and date.timezone is not set
// in php.ini, then calling date functions will cause a system call and
// PHP will issue an E_STRICT or E_WARNING error depending on PHP version.
// @todo: consider always setting the date_default_timezone variable from
// the installer.
return variable_get('date_default_timezone');
}
}
/**
* Set the timezone for a request when configured.
*/
function drupal_set_configured_timezone() {
$configured_timezone = drupal_get_user_timezone();
$system_timezone = ini_get('date.timezone');
// There is no point setting the timezone if it is configured the same
// as date.timezone in php.ini. Also date_default_timezone_set() validates
// the timezone, which relies on a system call to get the timezone database.
if ($configured_timezone != $system_timezone) {
date_default_timezone_set($configured_timezone);
}
}
......@@ -2046,7 +2064,6 @@ function _drupal_bootstrap_page_cache() {
// Restore the metadata cached with the page.
$_GET['q'] = $cache->data['path'];
drupal_set_title($cache->data['title'], PASS_THROUGH);
date_default_timezone_set(drupal_get_user_timezone());
// If the skipping of the bootstrap hooks is not enforced, call
// hook_boot.
if (variable_get('page_cache_invoke_hooks', TRUE)) {
......
This diff is collapsed.
......@@ -259,7 +259,7 @@ function drupal_session_initialize() {
// a user becomes authenticated.
session_id(drupal_hash_base64(uniqid(mt_rand(), TRUE)));
}
date_default_timezone_set(drupal_get_user_timezone());
drupal_set_configured_timezone();
}
/**
......@@ -387,7 +387,7 @@ function drupal_session_regenerate() {
drupal_session_start();
$user = $account;
}
date_default_timezone_set(drupal_get_user_timezone());
drupal_set_configured_timezone();
}
/**
......
......@@ -2226,7 +2226,7 @@ class FormatDateUnitTest extends DrupalWebTestCase {
$real_language = $language->language;
$language->language = $user->language;
// Simulate a Drupal bootstrap with the logged-in user.
date_default_timezone_set(drupal_get_user_timezone());
drupal_set_configured_timezone();
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', t('Test a different language.'));
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', t('Test a different time zone.'));
......@@ -2240,7 +2240,7 @@ class FormatDateUnitTest extends DrupalWebTestCase {
$user = $real_user;
$language->language = $real_language;
// Restore default time zone.
date_default_timezone_set(drupal_get_user_timezone());
drupal_set_configured_timezone();
drupal_save_session(TRUE);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment