X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FCore%2FSettingsManager.php;h=d3cb26f01f1f3f41fe14358d6c57fea5d155ff05;hb=2099e281172b0622067cc4791d032155c9156e42;hp=e56d723b2fbaf501a18acd9953530bd9462b872b;hpb=be58c28acdd8454dd2765a9fa4a63d2c4a9e0d12;p=civicrm-core.git diff --git a/Civi/Core/SettingsManager.php b/Civi/Core/SettingsManager.php index e56d723b2f..d3cb26f01f 100644 --- a/Civi/Core/SettingsManager.php +++ b/Civi/Core/SettingsManager.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -171,13 +171,24 @@ class SettingsManager { /** * @param int|NULL $domainId + * For the default domain, leave $domainID as NULL. * @param int|NULL $contactId + * For the default/active user's contact, leave $domainID as NULL. * @return SettingsBag + * @throws \CRM_Core_Exception + * If there is no contact, then there's no SettingsBag, and we'll throw + * an exception. */ public function getBagByContact($domainId, $contactId) { if ($domainId === NULL) { $domainId = \CRM_Core_Config::domainID(); } + if ($contactId === NULL) { + $contactId = \CRM_Core_Session::getLoggedInContactID(); + if (!$contactId) { + throw new \CRM_Core_Exception("Cannot access settings subsystem - user or domain is unavailable"); + } + } $key = "$domainId:$contactId"; if (!isset($this->bagsByContact[$key])) {