@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make timezone configuration impossible to get wrong

Summary: Fixes T2269. If the user manages to mess up both the PHP and Phabricator configurations, set the timezone to UTC. We basically never use this anyway (we always render into the user's time), PHP just gets angry at us if we don't set it. (We do use it for logged-out users, I suppose.)

Test Plan: Set PHP and Phabricator timezones to goofy nonsense, verified we recover sensibly from it.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2228, T2269

Differential Revision: https://secure.phabricator.com/D4496

+27 -35
+20
src/applications/config/check/PhabricatorSetupCheckTimezone.php
··· 3 3 final class PhabricatorSetupCheckTimezone extends PhabricatorSetupCheck { 4 4 5 5 protected function executeChecks() { 6 + $php_value = ini_get('date.timezone'); 7 + if ($php_value) { 8 + $old = date_default_timezone_get(); 9 + $ok = @date_default_timezone_set($php_value); 10 + date_default_timezone_set($old); 11 + 12 + if (!$ok) { 13 + $message = pht( 14 + 'Your PHP configuration configuration selects an invalid timezone. '. 15 + 'Select a valid timezone.'); 16 + 17 + $this 18 + ->newIssue('php.date.timezone') 19 + ->setShortName(pht('PHP Timezone')) 20 + ->setName(pht('PHP Timezone Invalid')) 21 + ->setMessage($message) 22 + ->addPHPConfig('date.timezone'); 23 + } 24 + } 25 + 6 26 $timezone = nonempty( 7 27 PhabricatorEnv::getEnvConfig('phabricator.timezone'), 8 28 ini_get('date.timezone'));
-34
src/infrastructure/PhabricatorSetup.php
··· 358 358 } 359 359 } 360 360 361 - $timezone = nonempty( 362 - PhabricatorEnv::getEnvConfig('phabricator.timezone'), 363 - ini_get('date.timezone')); 364 - if (!$timezone) { 365 - self::writeFailure(); 366 - self::write( 367 - "Setup failure! Your configuration fails to specify a server ". 368 - "timezone. Either set 'date.timezone' in your php.ini or ". 369 - "'phabricator.timezone' in your Phabricator configuration. See the ". 370 - "PHP documentation for a list of supported timezones:\n\n". 371 - "http://www.php.net/manual/en/timezones.php\n"); 372 - return; 373 - } else { 374 - self::write(" okay Timezone '{$timezone}' configured.\n"); 375 - } 376 - 377 361 self::write("[OKAY] Basic configuration OKAY\n"); 378 362 379 363 ··· 585 569 } 586 570 } else { 587 571 self::write(" skip Not configured for local disk storage.\n"); 588 - } 589 - 590 - $selector = PhabricatorEnv::getEnvConfig('storage.engine-selector'); 591 - 592 - try { 593 - $storage_selector_exists = class_exists($selector); 594 - } catch (Exception $ex) { 595 - $storage_selector_exists = false; 596 - } 597 - 598 - if ($storage_selector_exists) { 599 - self::write(" okay Using '{$selector}' as a storage engine selector.\n"); 600 - } else { 601 - self::writeFailure(); 602 - self::write( 603 - "Setup failure! You have configured '{$selector}' as a storage engine ". 604 - "selector but it does not exist or could not be loaded.\n"); 605 - return; 606 572 } 607 573 608 574 self::write("[OKAY] Database and storage configuration OKAY\n");
+7 -1
src/infrastructure/env/PhabricatorEnv.php
··· 107 107 108 108 self::buildConfigurationSourceStack(); 109 109 110 + // Force a valid timezone. If both PHP and Phabricator configuration are 111 + // invalid, use UTC. 110 112 $tz = PhabricatorEnv::getEnvConfig('phabricator.timezone'); 111 113 if ($tz) { 112 - date_default_timezone_set($tz); 114 + @date_default_timezone_set($tz); 115 + } 116 + $ok = @date_default_timezone_set(date_default_timezone_get()); 117 + if (!$ok) { 118 + date_default_timezone_set('UTC'); 113 119 } 114 120 115 121 // Append any paths to $PATH if we need to.