CRM-16373 - CRM_Admin_Form_Setting - Generate error instead of saving config fields
authorTim Otten <totten@civicrm.org>
Tue, 8 Sep 2015 00:14:32 +0000 (17:14 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 17 Sep 2015 22:49:29 +0000 (15:49 -0700)
CRM/Admin/Form/Setting.php
CRM/Core/BAO/ConfigSetting.php

index 6122a154542f870a5f6b4746ff3f5505c4df24c6..2e1aed0fb988ebd39cc805974bd992f322c2f613 100644 (file)
@@ -267,7 +267,11 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
       CRM_Core_Session::setStatus($result['error_message'], ts('Save Failed'), 'error');
     }
 
-    CRM_Core_BAO_ConfigSetting::create($params);
+    //CRM_Core_BAO_ConfigSetting::create($params);
+    $params = CRM_Core_BAO_ConfigSetting::filterSkipVars($params);
+    if (!empty($params)) {
+      CRM_Core_Error::fatal('Unrecognized setting. This may be a config field which has not been properly migrated to a setting. (' . implode(', ', array_keys($params)) . ')');
+    }
 
     CRM_Core_Config::clearDBCache();
     CRM_Utils_System::flushCache();
index 6c7dcf43422946f2f6cca9eb131ee4e9ade2a9df..051d7352a60ab768ad2584ffa043f10871b20404 100644 (file)
@@ -66,13 +66,7 @@ class CRM_Core_BAO_ConfigSetting {
       $params = array_merge(unserialize($domain->config_backend), $params);
     }
 
-    // unset any of the variables we read from file that should not be stored in the database
-    // the username and certpath are stored flat with _test and _live
-    // check CRM-1470
-    $skipVars = self::skipVars();
-    foreach ($skipVars as $var) {
-      unset($params[$var]);
-    }
+    $params = CRM_Core_BAO_ConfigSetting::filterSkipVars($params);
 
     // also skip all Dir Params, we dont need to store those in the DB!
     foreach ($params as $name => $val) {
@@ -626,6 +620,7 @@ WHERE  option_group_id = (
       'qfKey',
       'gettextResourceDir',
       'cleanURL',
+      'entryURL',
       'locale_custom_strings',
       'localeCustomStrings',
       'autocompleteContactSearch',
@@ -635,4 +630,21 @@ WHERE  option_group_id = (
     );
   }
 
+  /**
+   * @param array $params
+   * @return array
+   */
+  public static function filterSkipVars($params) {
+    $skipVars = self::skipVars();
+    foreach ($skipVars as $var) {
+      unset($params[$var]);
+    }
+    foreach (array_keys($params) as $key) {
+      if (preg_match('/^_qf_/', $key)) {
+        unset($params[$key]);
+      }
+    }
+    return $params;
+  }
+
 }