From 0b4413ac0f3957625b32781cdff76eef3171d5f6 Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Fri, 4 Mar 2016 14:33:30 +0100 Subject: [PATCH] Bugfix: do not set the timezone as initialized if it wasn't! --- lib/SimpleSAML/Utils/Time.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/SimpleSAML/Utils/Time.php b/lib/SimpleSAML/Utils/Time.php index 66d8a4e30..3eebe50b5 100644 --- a/lib/SimpleSAML/Utils/Time.php +++ b/lib/SimpleSAML/Utils/Time.php @@ -13,6 +13,14 @@ use SimpleSAML\Logger; class Time { + /** + * Whether the timezone has been initialized or not. + * + * @var bool + */ + private static $tz_initialized = false; + + /** * This function generates a timestamp on the form used by the SAML protocols. * @@ -39,14 +47,10 @@ class Time */ public static function initTimezone() { - static $initialized = false; - - if ($initialized) { + if (self::$tz_initialized) { return; } - $initialized = true; - $globalConfig = \SimpleSAML_Configuration::getInstance(); $timezone = $globalConfig->getString('timezone', null); @@ -54,6 +58,7 @@ class Time if (!date_default_timezone_set($timezone)) { throw new \SimpleSAML_Error_Exception('Invalid timezone set in the "timezone" option in config.php.'); } + self::$tz_initialized = true; return; } // we don't have a timezone configured @@ -64,6 +69,7 @@ class Time // set the timezone to the default date_default_timezone_set($serverTimezone); + self::$tz_initialized = true; } -- GitLab