2012-12-31 02:04:38 +01:00
|
|
|
<?php
|
|
|
|
|
2015-01-02 05:27:45 +01:00
|
|
|
final class PhabricatorTimezoneSetupCheck extends PhabricatorSetupCheck {
|
2012-12-31 02:04:38 +01:00
|
|
|
|
2015-02-10 21:53:00 +01:00
|
|
|
public function getDefaultGroup() {
|
|
|
|
return self::GROUP_OTHER;
|
|
|
|
}
|
|
|
|
|
2012-12-31 02:04:38 +01:00
|
|
|
protected function executeChecks() {
|
2013-01-19 17:38:37 +01:00
|
|
|
$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(
|
2015-06-27 17:43:44 +02:00
|
|
|
'Your PHP configuration selects an invalid timezone. '.
|
2013-01-19 17:38:37 +01:00
|
|
|
'Select a valid timezone.');
|
|
|
|
|
|
|
|
$this
|
|
|
|
->newIssue('php.date.timezone')
|
|
|
|
->setShortName(pht('PHP Timezone'))
|
|
|
|
->setName(pht('PHP Timezone Invalid'))
|
|
|
|
->setMessage($message)
|
|
|
|
->addPHPConfig('date.timezone');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-31 02:04:38 +01:00
|
|
|
$timezone = nonempty(
|
|
|
|
PhabricatorEnv::getEnvConfig('phabricator.timezone'),
|
|
|
|
ini_get('date.timezone'));
|
|
|
|
if ($timezone) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$summary = pht(
|
2014-06-09 20:36:49 +02:00
|
|
|
'Without a configured timezone, PHP will emit warnings when working '.
|
|
|
|
'with dates, and dates and times may not display correctly.');
|
2012-12-31 02:04:38 +01:00
|
|
|
|
|
|
|
$message = pht(
|
|
|
|
"Your configuration fails to specify a server timezone. You can either ".
|
2015-05-22 09:27:56 +02:00
|
|
|
"set the PHP configuration value '%s' or the Phabricator ".
|
|
|
|
"configuration value '%s' to specify one.",
|
|
|
|
'date.timezone',
|
|
|
|
'phabricator.timezone');
|
2012-12-31 02:04:38 +01:00
|
|
|
|
|
|
|
$this
|
|
|
|
->newIssue('config.timezone')
|
|
|
|
->setShortName(pht('Timezone'))
|
|
|
|
->setName(pht('Server Timezone Not Configured'))
|
|
|
|
->setSummary($summary)
|
|
|
|
->setMessage($message)
|
|
|
|
->addPHPConfig('date.timezone')
|
|
|
|
->addPhabricatorConfig('phabricator.timezone');
|
|
|
|
}
|
|
|
|
}
|