X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FCore%2FSettingsManager.php;h=cca82f79dec907c1138cda0889073f9b77d467a7;hb=9738d3b55f8433699a146f4a6c4e76583c17778b;hp=e56d723b2fbaf501a18acd9953530bd9462b872b;hpb=784dd9c4af443a34a95682ecfda7e44bd69481ae;p=civicrm-core.git diff --git a/Civi/Core/SettingsManager.php b/Civi/Core/SettingsManager.php index e56d723b2f..cca82f79de 100644 --- a/Civi/Core/SettingsManager.php +++ b/Civi/Core/SettingsManager.php @@ -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])) {