From 7e0c769c0c75ab45f108fdc0a5f85eb412c4b1b7 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 7 Sep 2015 17:14:32 -0700 Subject: [PATCH] CRM-16373 - CRM_Admin_Form_Setting - Generate error instead of saving config fields --- CRM/Admin/Form/Setting.php | 6 +++++- CRM/Core/BAO/ConfigSetting.php | 26 +++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CRM/Admin/Form/Setting.php b/CRM/Admin/Form/Setting.php index 6122a15454..2e1aed0fb9 100644 --- a/CRM/Admin/Form/Setting.php +++ b/CRM/Admin/Form/Setting.php @@ -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(); diff --git a/CRM/Core/BAO/ConfigSetting.php b/CRM/Core/BAO/ConfigSetting.php index 6c7dcf4342..051d7352a6 100644 --- a/CRM/Core/BAO/ConfigSetting.php +++ b/CRM/Core/BAO/ConfigSetting.php @@ -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; + } + } -- 2.25.1