diff --git a/src/applications/config/check/PhabricatorSetupCheckTimezone.php b/src/applications/config/check/PhabricatorSetupCheckTimezone.php index 834afb14b1..ebff55f6f6 100644 --- a/src/applications/config/check/PhabricatorSetupCheckTimezone.php +++ b/src/applications/config/check/PhabricatorSetupCheckTimezone.php @@ -3,6 +3,26 @@ final class PhabricatorSetupCheckTimezone extends PhabricatorSetupCheck { protected function executeChecks() { + $php_value = ini_get('date.timezone'); + if ($php_value) { + $old = date_default_timezone_get(); + $ok = @date_default_timezone_set($php_value); + date_default_timezone_set($old); + + if (!$ok) { + $message = pht( + 'Your PHP configuration configuration selects an invalid timezone. '. + 'Select a valid timezone.'); + + $this + ->newIssue('php.date.timezone') + ->setShortName(pht('PHP Timezone')) + ->setName(pht('PHP Timezone Invalid')) + ->setMessage($message) + ->addPHPConfig('date.timezone'); + } + } + $timezone = nonempty( PhabricatorEnv::getEnvConfig('phabricator.timezone'), ini_get('date.timezone')); diff --git a/src/infrastructure/PhabricatorSetup.php b/src/infrastructure/PhabricatorSetup.php index 7e7edfef15..8645b9c729 100644 --- a/src/infrastructure/PhabricatorSetup.php +++ b/src/infrastructure/PhabricatorSetup.php @@ -358,22 +358,6 @@ final class PhabricatorSetup { } } - $timezone = nonempty( - PhabricatorEnv::getEnvConfig('phabricator.timezone'), - ini_get('date.timezone')); - if (!$timezone) { - self::writeFailure(); - self::write( - "Setup failure! Your configuration fails to specify a server ". - "timezone. Either set 'date.timezone' in your php.ini or ". - "'phabricator.timezone' in your Phabricator configuration. See the ". - "PHP documentation for a list of supported timezones:\n\n". - "http://www.php.net/manual/en/timezones.php\n"); - return; - } else { - self::write(" okay Timezone '{$timezone}' configured.\n"); - } - self::write("[OKAY] Basic configuration OKAY\n"); @@ -587,24 +571,6 @@ final class PhabricatorSetup { self::write(" skip Not configured for local disk storage.\n"); } - $selector = PhabricatorEnv::getEnvConfig('storage.engine-selector'); - - try { - $storage_selector_exists = class_exists($selector); - } catch (Exception $ex) { - $storage_selector_exists = false; - } - - if ($storage_selector_exists) { - self::write(" okay Using '{$selector}' as a storage engine selector.\n"); - } else { - self::writeFailure(); - self::write( - "Setup failure! You have configured '{$selector}' as a storage engine ". - "selector but it does not exist or could not be loaded.\n"); - return; - } - self::write("[OKAY] Database and storage configuration OKAY\n"); self::writeHeader('SUCCESS!'); diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php index 79c6b40c49..627b70bcbc 100644 --- a/src/infrastructure/env/PhabricatorEnv.php +++ b/src/infrastructure/env/PhabricatorEnv.php @@ -107,9 +107,15 @@ final class PhabricatorEnv { self::buildConfigurationSourceStack(); + // Force a valid timezone. If both PHP and Phabricator configuration are + // invalid, use UTC. $tz = PhabricatorEnv::getEnvConfig('phabricator.timezone'); if ($tz) { - date_default_timezone_set($tz); + @date_default_timezone_set($tz); + } + $ok = @date_default_timezone_set(date_default_timezone_get()); + if (!$ok) { + date_default_timezone_set('UTC'); } // Append any paths to $PATH if we need to.