@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.

Validate timezones

Summary:
Add validation for timezones, since date_default_timezone_set() returns a usable error code.

Note that we could also list all the timezones using timezone_identifiers_list(), but the list is enormous (many hundreds of entries) and impossible to use (~160 entries in "America" alone). I listed the likely US values as examples but left it as a string input text field.

Test Plan: Tried to save an invalid setting. Saved a valid setting.

Reviewers: codeblock, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2255

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

+25 -1
+25 -1
src/applications/config/option/PhabricatorCoreConfigOptions.php
··· 46 46 "possible (for instance, because you are using HPHP) you can set ". 47 47 "some valid constant for date_default_timezone_set() here and ". 48 48 "Phabricator will set it on your behalf, silencing the warning.")) 49 - ->addExample('America/New_York', 'Valid Setting'), 49 + ->addExample('America/New_York', pht('US East (EDT)')) 50 + ->addExample('America/Chicago', pht('US Central (CDT)')) 51 + ->addExample('America/Boise', pht('US Mountain (MDT)')) 52 + ->addExample('America/Los_Angeles', pht('US West (PDT)')), 50 53 $this->newOption('phabricator.serious-business', 'bool', false) 51 54 ->setOptions( 52 55 array( ··· 132 135 $key)); 133 136 } 134 137 } 138 + 139 + 140 + if ($key === 'phabricator.timezone') { 141 + $old = date_default_timezone_get(); 142 + $ok = @date_default_timezone_set($value); 143 + @date_default_timezone_set($old); 144 + 145 + if (!$ok) { 146 + throw new PhabricatorConfigValidationException( 147 + pht( 148 + "Config option '%s' is invalid. The timezone identifier must ". 149 + "be a valid timezone identifier recognized by PHP, like ". 150 + "'America/Los_Angeles'. You can find a list of valid identifiers ". 151 + "here: %s", 152 + $key, 153 + 'http://php.net/manual/timezones.php')); 154 + } 155 + } 156 + 157 + 158 + 135 159 } 136 160 137 161