diff --git a/lib/SimpleSAML/Utils/Time.php b/lib/SimpleSAML/Utils/Time.php index 66d8a4e303957a169eb66ae0bacd292df58218d6..3eebe50b5251aad60c238981e3257dc71c923c6b 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; }