From 889bb14112391535ba43e19ab4bd4663463cc118 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 12 Nov 2019 22:14:57 -0800 Subject: [PATCH] (dev/core#1387) ConfigSetting - Deprecation+guard for retrieve()/add() These functions were traditionally used for accessing `config_backend`, which was (mostly) dropped in v4.7 and became inert. However, the functions are still referenced in a couple oddball cases. Note that the references to `$domain->config_backend` are liable to raise warnings if evaluated - since the field no longer exists on the DAO class. Consequently, the extra `$hasBackend` guard should reduce warnings. --- CRM/Core/BAO/ConfigSetting.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/ConfigSetting.php b/CRM/Core/BAO/ConfigSetting.php index 9241b41477..359685a8cf 100644 --- a/CRM/Core/BAO/ConfigSetting.php +++ b/CRM/Core/BAO/ConfigSetting.php @@ -41,6 +41,9 @@ class CRM_Core_BAO_ConfigSetting { * * @param array $params * Associated array of civicrm variables. + * @deprecated + * This method was historically used to access civicrm_domain.config_backend. + * However, that has been fully replaced by the settings system since v4.7. */ public static function add(&$params) { $domain = new CRM_Core_DAO_Domain(); @@ -69,6 +72,9 @@ class CRM_Core_BAO_ConfigSetting { * @param $defaults * * @return array + * @deprecated + * This method was historically used to access civicrm_domain.config_backend. + * However, that has been fully replaced by the settings system since v4.7. */ public static function retrieve(&$defaults) { $domain = new CRM_Core_DAO_Domain(); @@ -80,7 +86,8 @@ class CRM_Core_BAO_ConfigSetting { $urlVar = 'task'; } - if ($isUpgrade && CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_domain', 'config_backend')) { + $hasBackend = CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_domain', 'config_backend'); + if ($isUpgrade && $hasBackend) { $domain->selectAdd('config_backend'); } else { @@ -89,7 +96,10 @@ class CRM_Core_BAO_ConfigSetting { $domain->id = CRM_Core_Config::domainID(); $domain->find(TRUE); - if ($domain->config_backend) { + if ($hasBackend && $domain->config_backend) { + // This whole branch can probably be removed; the transitional loading + // is in SettingBag::loadValues(). Moreover, since 4.7.alpha1 dropped + // the column, anyone calling ::retrieve() has likely not gotten any data. $defaults = unserialize($domain->config_backend); if ($defaults === FALSE || !is_array($defaults)) { $defaults = []; -- 2.25.1