Page MenuHomePhabricator

D16035.id38601.diff
No OneTemporary

D16035.id38601.diff

diff --git a/src/applications/settings/controller/PhabricatorSettingsAdjustController.php b/src/applications/settings/controller/PhabricatorSettingsAdjustController.php
--- a/src/applications/settings/controller/PhabricatorSettingsAdjustController.php
+++ b/src/applications/settings/controller/PhabricatorSettingsAdjustController.php
@@ -4,13 +4,23 @@
extends PhabricatorController {
public function handleRequest(AphrontRequest $request) {
- $user = $request->getUser();
+ $viewer = $this->getViewer();
- $prefs = $user->loadPreferences();
- $prefs->setPreference(
- $request->getStr('key'),
- $request->getStr('value'));
- $prefs->save();
+ $preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
+
+ $editor = id(new PhabricatorUserPreferencesEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true);
+
+ $key = $request->getStr('key');
+ $value = $request->getStr('value');
+
+ $xactions = array();
+ $xactions[] = $preferences->newTransaction($key, $value);
+
+ $editor->applyTransactions($preferences, $xactions);
return id(new AphrontAjaxResponse())->setContent(array());
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 29, 10:04 AM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223150
Default Alt Text
D16035.id38601.diff (1 KB)

Event Timeline