MagicMerge - Changes to properties should not be persistent across requests
authorTim Otten <totten@civicrm.org>
Wed, 16 Sep 2015 02:30:00 +0000 (19:30 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 17 Sep 2015 22:49:32 +0000 (15:49 -0700)
CRM/Core/Config/MagicMerge.php

index d509a4f4015c6bd01dccf35082858a8301840892..46ff1ec1526c505758a41a9fd7e6eb54d590f267 100644 (file)
@@ -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':