Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15337744
D16037.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D16037.diff
View Options
diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php
--- a/src/applications/people/storage/PhabricatorUser.php
+++ b/src/applications/people/storage/PhabricatorUser.php
@@ -533,20 +533,6 @@
return ($actual == $value);
}
-
- /**
- * @task settings
- */
- public function clearUserSettingCache() {
- $this->settingCacheKeys = array();
- $this->settingCache = array();
-
- $settings_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES;
- $this->clearCacheData($settings_key);
-
- return $this;
- }
-
private function writeUserSettingCache($key, $value) {
$this->settingCacheKeys[$key] = true;
$this->settingCache[$key] = $value;
diff --git a/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php b/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
--- a/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
+++ b/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
@@ -27,18 +27,18 @@
$settings_help = pht(
'You can change your date and time preferences in Settings.');
+ $did_calibrate = false;
if ($request->isFormPost()) {
$timezone = $request->getStr('timezone');
$pref_ignore = PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY;
$pref_timezone = PhabricatorTimezoneSetting::SETTINGKEY;
- $preferences = $viewer->loadPreferences();
-
if ($timezone == 'ignore') {
- $preferences
- ->setPreference($pref_ignore, $client_offset)
- ->save();
+ $this->writeSettings(
+ array(
+ $pref_ignore => $client_offset,
+ ));
return $this->newDialog()
->setTitle(pht('Conflict Ignored'))
@@ -51,18 +51,19 @@
}
if (isset($options[$timezone])) {
- $preferences
- ->setPreference($pref_ignore, null)
- ->setPreference($pref_timezone, $timezone)
- ->save();
+ $this->writeSettings(
+ array(
+ $pref_ignore => null,
+ $pref_timezone => $timezone,
+ ));
- $viewer->clearUserSettingCache();
+ $did_calibrate = true;
}
}
$server_offset = $viewer->getTimeZoneOffset();
- if ($client_offset == $server_offset) {
+ if ($client_offset == $server_offset || $did_calibrate) {
return $this->newDialog()
->setTitle(pht('Timezone Calibrated'))
->appendParagraph(
@@ -121,4 +122,24 @@
}
}
+ private function writeSettings(array $map) {
+ $request = $this->getRequest();
+ $viewer = $this->getViewer();
+
+ $preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
+
+ $editor = id(new PhabricatorUserPreferencesEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true);
+
+ $xactions = array();
+ foreach ($map as $key => $value) {
+ $xactions[] = $preferences->newTransaction($key, $value);
+ }
+
+ $editor->applyTransactions($preferences, $xactions);
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 10, 7:31 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223220
Default Alt Text
D16037.diff (3 KB)
Attached To
Mode
D16037: Resolve timezone conflicts in a modern transactional way
Attached
Detach File
Event Timeline
Log In to Comment