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

When a user changes their timezone, clear their ignored timezone offset

Summary:
Ref T4103. We have a couple of settings like this where changing one setting changes another (e.g., enabling DarkConsole makes the console visible).

Provide a mechanism to let changing timezone really mean "change timezone, and also clear the timezone offset".

Test Plan: Swapped timezones, reconciled them by ignoring the offset, changed timezone again to another zone with the same offset, got asked to reconcile again.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4103

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

+57 -9
+31 -9
src/applications/settings/editor/PhabricatorUserPreferencesEditor.php
··· 19 19 return $types; 20 20 } 21 21 22 + protected function expandTransaction( 23 + PhabricatorLiskDAO $object, 24 + PhabricatorApplicationTransaction $xaction) { 25 + 26 + $setting_key = $xaction->getMetadataValue( 27 + PhabricatorUserPreferencesTransaction::PROPERTY_SETTING); 28 + 29 + $settings = $this->getSettings(); 30 + $setting = idx($settings, $setting_key); 31 + if ($setting) { 32 + return $setting->expandSettingTransaction($object, $xaction); 33 + } 34 + 35 + return parent::expandTransaction($object, $xaction); 36 + } 37 + 38 + 22 39 protected function getCustomTransactionOldValue( 23 40 PhabricatorLiskDAO $object, 24 41 PhabricatorApplicationTransaction $xaction) { ··· 95 112 array $xactions) { 96 113 97 114 $errors = parent::validateTransaction($object, $type, $xactions); 98 - 99 - $actor = $this->getActor(); 100 - $settings = PhabricatorSetting::getAllEnabledSettings($actor); 101 - 102 - foreach ($settings as $key => $setting) { 103 - $setting = clone $setting; 104 - $setting->setViewer($actor); 105 - $settings[$key] = $setting; 106 - } 115 + $settings = $this->getSettings(); 107 116 108 117 switch ($type) { 109 118 case PhabricatorUserPreferencesTransaction::TYPE_SETTING: ··· 155 164 156 165 157 166 return $xactions; 167 + } 168 + 169 + private function getSettings() { 170 + $actor = $this->getActor(); 171 + $settings = PhabricatorSetting::getAllEnabledSettings($actor); 172 + 173 + foreach ($settings as $key => $setting) { 174 + $setting = clone $setting; 175 + $setting->setViewer($actor); 176 + $settings[$key] = $setting; 177 + } 178 + 179 + return $settings; 158 180 } 159 181 160 182 }
+14
src/applications/settings/setting/PhabricatorSetting.php
··· 111 111 return $value; 112 112 } 113 113 114 + public function expandSettingTransaction($object, $xaction) { 115 + return array($xaction); 116 + } 117 + 118 + protected function newSettingTransaction($object, $key, $value) { 119 + $setting_property = PhabricatorUserPreferencesTransaction::PROPERTY_SETTING; 120 + $xaction_type = PhabricatorUserPreferencesTransaction::TYPE_SETTING; 121 + 122 + return id(clone $object->getApplicationTransactionTemplate()) 123 + ->setTransactionType($xaction_type) 124 + ->setMetadataValue($setting_property, $key) 125 + ->setNewValue($value); 126 + } 127 + 114 128 }
+12
src/applications/settings/setting/PhabricatorTimezoneSetting.php
··· 87 87 return $option_groups; 88 88 } 89 89 90 + public function expandSettingTransaction($object, $xaction) { 91 + // When the user changes their timezone, we also clear any ignored 92 + // timezone offset. 93 + return array( 94 + $xaction, 95 + $this->newSettingTransaction( 96 + $object, 97 + PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY, 98 + null), 99 + ); 100 + } 101 + 90 102 }