@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 select/option settings more strictly when reading them

Summary:
Ref T4103. If the database has `""` (empty string) for select/option settings, we can let that value be effective in the UI right now.

One consequence is that timestamps can vanish from the UI.

Instead, be stricter and discard it as an invalid value.

Test Plan:
- Forced `time-format` setting to `''`.
- Saw timestamps vanish before change.
- Saw timestamps return to the default value after change.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4103

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

+19
+19
src/applications/settings/setting/PhabricatorSelectSetting.php
··· 27 27 ->setOptions($options); 28 28 } 29 29 30 + public function assertValidValue($value) { 31 + // This is a slightly stricter check than the transaction check. It's 32 + // OK for empty string to go through transactions because it gets converted 33 + // to null later, but we shouldn't be reading the empty string from 34 + // storage. 35 + if ($value === null) { 36 + return; 37 + } 38 + 39 + if (!strlen($value)) { 40 + throw new Exception( 41 + pht( 42 + 'Empty string is not a valid setting for "%s".', 43 + $this->getSettingName())); 44 + } 45 + 46 + $this->validateTransactionValue($value); 47 + } 48 + 30 49 final public function validateTransactionValue($value) { 31 50 if (!strlen($value)) { 32 51 return;