From: Tim Otten Date: Wed, 16 Sep 2015 02:30:00 +0000 (-0700) Subject: MagicMerge - Changes to properties should not be persistent across requests X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=dc640254bd649040b5200ffeb15d1bf7da55bf1c;p=civicrm-core.git MagicMerge - Changes to properties should not be persistent across requests --- diff --git a/CRM/Core/Config/MagicMerge.php b/CRM/Core/Config/MagicMerge.php index d509a4f401..46ff1ec152 100644 --- a/CRM/Core/Config/MagicMerge.php +++ b/CRM/Core/Config/MagicMerge.php @@ -251,15 +251,18 @@ class CRM_Core_Config_MagicMerge { throw new \CRM_Core_Exception("Cannot set unrecognized property CRM_Core_Config::\${$k}"); } unset($this->cache[$k]); - list ($type, $name) = $this->map[$k]; + $type = $this->map[$k][0]; + $name = isset($this->map[$k][1]) ? $this->map[$k][1] : $k; switch ($type) { case 'setting': - $this->getSettings()->set($name, $v); - return; - + case 'setting-path': + case 'setting-url-abs': + case 'setting-url-rel': case 'runtime': - $this->getRuntime()->{$name} = $v; + case 'callback': + // In the past, changes to $config were not persisted automatically. + $this->cache[$name] = $v; return; case 'local': @@ -267,14 +270,6 @@ class CRM_Core_Config_MagicMerge { $this->locals[$name] = $v; return; - case 'callback': - // Array(0 => $type, 1 => $obj, 2 => $getter, 3 => $setter, 4 => $unsetter). - if (!isset($this->map[$k][1], $this->map[$k][3])) { - throw new \CRM_Core_Exception("Cannot find setter for property CRM_Core_Config::\${$k}"); - } - \Civi\Core\Resolver::singleton()->call(array($this->map[$k][1], $this->map[$k][3]), array($k, $v)); - return; - default: throw new \CRM_Core_Exception("Cannot set property CRM_Core_Config::\${$k} ($type)"); } @@ -289,7 +284,8 @@ class CRM_Core_Config_MagicMerge { throw new \CRM_Core_Exception("Cannot unset unrecognized property CRM_Core_Config::\${$k}"); } unset($this->cache[$k]); - list ($type, $name) = $this->map[$k]; + $type = $this->map[$k][0]; + $name = isset($this->map[$k][1]) ? $this->map[$k][1] : $k; switch ($type) { case 'setting':