From a1025ca52e031a41b206db00da66326b779e2b24 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 23 Nov 2016 14:05:13 -0800 Subject: [PATCH] Make logged-out users use global settings, not default settings Summary: Fixes T11917. Give logged-out / omnipotent users the global settings, not the default settings. Test Plan: Changed applications and language, logged out, saw changes as a public user. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11917 Differential Revision: https://secure.phabricator.com/D16936 --- .../people/storage/PhabricatorUser.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php index e20c68f782..bc102b7275 100644 --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -487,7 +487,7 @@ final class PhabricatorUser if ($this->getPHID()) { $settings = $this->requireCacheData($settings_key); } else { - $settings = array(); + $settings = $this->loadGlobalSettings(); } // NOTE: To slightly improve performance, we're using all settings here, @@ -555,6 +555,20 @@ final class PhabricatorUser return $this->getUserSetting(PhabricatorTimezoneSetting::SETTINGKEY); } + private function loadGlobalSettings() { + $cache_key = 'user.settings.global'; + $cache = PhabricatorCaches::getRequestCache(); + $settings = $cache->getKey($cache_key); + + if ($settings === null) { + $preferences = PhabricatorUserPreferences::loadGlobalPreferences($this); + $settings = $preferences->getPreferences(); + $cache->setKey($cache_key, $settings); + } + + return $settings; + } + /** * Override the user's timezone identifier.