Merge pull request #14534 from pradpnayak/EventTypeQuery
[civicrm-core.git] / CRM / Core / Config / MagicMerge.php
index 90aa741bf8b479d2129f817d776f3b64e3565b4a..30188ce3bfc878e310754d5ea7c9735443d7147b 100644 (file)
@@ -54,7 +54,8 @@ class CRM_Core_Config_MagicMerge {
    */
   private $map;
 
-  private $locals, $settings;
+  private $locals;
+  private $settings;
 
   private $cache = [];
 
@@ -105,8 +106,6 @@ class CRM_Core_Config_MagicMerge {
       'userFrameworkURLVar' => ['runtime'],
       'userHookClass' => ['runtime'],
       'cleanURL' => ['runtime'],
-      'configAndLogDir' => ['runtime'],
-      'templateCompileDir' => ['runtime'],
       'templateDir' => ['runtime'],
 
       // "boot-svc" properties are critical services needed during init.
@@ -116,7 +115,8 @@ class CRM_Core_Config_MagicMerge {
 
       'userFrameworkBaseURL' => ['user-system', 'getAbsoluteBaseURL'],
       'userFrameworkVersion' => ['user-system', 'getVersion'],
-      'useFrameworkRelativeBase' => ['user-system', 'getRelativeBaseURL'], // ugh typo.
+    // ugh typo.
+      'useFrameworkRelativeBase' => ['user-system', 'getRelativeBaseURL'],
 
       // "setting" properties are loaded through the setting layer, esp
       // table "civicrm_setting" and global $civicrm_setting.
@@ -133,14 +133,16 @@ class CRM_Core_Config_MagicMerge {
       'dateformatYear' => ['setting'],
       'dateformatFinancialBatch' => ['setting'],
       'dateformatshortdate' => ['setting'],
-      'debug' => ['setting', 'debug_enabled'], // renamed.
+      // renamed.
+      'debug' => ['setting', 'debug_enabled'],
       'defaultContactCountry' => ['setting'],
       'defaultContactStateProvince' => ['setting'],
       'defaultCurrency' => ['setting'],
       'defaultSearchProfileID' => ['setting'],
       'doNotAttachPDFReceipt' => ['setting'],
       'empoweredBy' => ['setting'],
-      'enableComponents' => ['setting', 'enable_components'], // renamed.
+      // renamed.
+      'enableComponents' => ['setting', 'enable_components'],
       'enableSSL' => ['setting'],
       'fatalErrorHandler' => ['setting'],
       'fieldSeparator' => ['setting'],
@@ -164,7 +166,8 @@ class CRM_Core_Config_MagicMerge {
       'mapAPIKey' => ['setting'],
       'mapProvider' => ['setting'],
       'maxFileSize' => ['setting'],
-      'maxAttachments' => ['setting', 'max_attachments'], // renamed.
+      // renamed.
+      'maxAttachments' => ['setting', 'max_attachments'],
       'monetaryDecimalPoint' => ['setting'],
       'monetaryThousandSeparator' => ['setting'],
       'moneyformat' => ['setting'],
@@ -185,6 +188,12 @@ class CRM_Core_Config_MagicMerge {
       'wpBasePage' => ['setting'],
       'wpLoadPhp' => ['setting'],
 
+      // "path" properties are managed via Civi::paths and $civicrm_paths
+      // Option: `mkdir` - auto-create dir
+      // Option: `restrict` - auto-restrict remote access
+      'configAndLogDir' => ['path', 'civicrm.log', ['mkdir', 'restrict']],
+      'templateCompileDir' => ['path', 'civicrm.compile', ['mkdir', 'restrict']],
+
       // "setting-path" properties are settings with special filtering
       // to return normalized file paths.
       // Option: `mkdir` - auto-create dir
@@ -236,10 +245,14 @@ class CRM_Core_Config_MagicMerge {
       case 'setting':
         return $this->getSettings()->get($name);
 
+      // The interpretation of 'path' and 'setting-path' is similar, except
+      // that the latter originates in a stored setting.
+      case 'path':
       case 'setting-path':
         // Array(0 => $type, 1 => $setting, 2 => $actions).
-        $value = $this->getSettings()->get($name);
-        $value = Civi::paths()->getPath($value);
+        $value = ($type === 'path')
+          ? Civi::paths()->getVariable($name, 'path')
+          : Civi::paths()->getPath($this->getSettings()->get($name));
         if ($value) {
           $value = CRM_Utils_File::addTrailingSlash($value);
           if (isset($this->map[$k][2]) && in_array('mkdir', $this->map[$k][2])) {
@@ -313,25 +326,22 @@ class CRM_Core_Config_MagicMerge {
     unset($this->cache[$k]);
     $type = $this->map[$k][0];
 
-    // If foreign name is set, use that name (except with callback types because
-    // their second parameter is the object, not the foreign name).
-    $name = isset($this->map[$k][1]) && $type != 'callback' ? $this->map[$k][1] : $k;
-
     switch ($type) {
       case 'setting':
       case 'setting-path':
       case 'setting-url':
+      case 'path':
       case 'user-system':
       case 'runtime':
       case 'callback':
       case 'boot-svc':
         // In the past, changes to $config were not persisted automatically.
-        $this->cache[$name] = $v;
+        $this->cache[$k] = $v;
         return;
 
       case 'local':
         $this->initLocals();
-        $this->locals[$name] = $v;
+        $this->locals[$k] = $v;
         return;
 
       default: