From 6a59e5105a95f7c30dc5f15d5e2a61525bc179eb Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 21 Apr 2017 15:08:33 +1200 Subject: [PATCH] CRM-20424 Add method to mark deprecation & ensure it causes test fail --- CRM/Contact/BAO/SearchCustom.php | 11 +++++------ CRM/Core/Error/Log.php | 4 ++++ CRM/Core/OptionGroup.php | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/BAO/SearchCustom.php b/CRM/Contact/BAO/SearchCustom.php index aec6a6491a..e13bc52c4f 100644 --- a/CRM/Contact/BAO/SearchCustom.php +++ b/CRM/Contact/BAO/SearchCustom.php @@ -71,12 +71,11 @@ class CRM_Contact_BAO_SearchCustom { // check that the csid exists in the db along with the right file // and implements the right interface - $customSearchClass = CRM_Core_OptionGroup::getLabel('custom_search', - $customSearchID - ); - if (!$customSearchClass) { - return $error; - } + $customSearchClass = civicrm_api3('OptionValue', 'getvalue', array( + 'option_group_id' => 'custom_search', + 'return' => 'name', + 'value' => $customSearchID, + )); $ext = CRM_Extension_System::singleton()->getMapper(); diff --git a/CRM/Core/Error/Log.php b/CRM/Core/Error/Log.php index 80a28cba02..a980395207 100644 --- a/CRM/Core/Error/Log.php +++ b/CRM/Core/Error/Log.php @@ -64,6 +64,10 @@ class CRM_Core_Error_Log extends \Psr\Log\AbstractLogger { $context['exception'] = CRM_Core_Error::formatTextException($context['exception']); } $message .= "\n" . print_r($context, 1); + + if (CRM_Utils_System::isDevelopment() && CRM_Utils_Array::value('civi.tag', $context) === 'deprecated') { + trigger_error($message, E_USER_DEPRECATED); + } } CRM_Core_Error::debug_log_message($message, FALSE, '', $this->map[$level]); } diff --git a/CRM/Core/OptionGroup.php b/CRM/Core/OptionGroup.php index 1227803a5f..89c8eb13d9 100644 --- a/CRM/Core/OptionGroup.php +++ b/CRM/Core/OptionGroup.php @@ -342,6 +342,7 @@ WHERE v.option_group_id = g.id * @return null */ public static function getLabel($groupName, $value, $onlyActiveValue = TRUE) { + Civi::log()->warning('Deprecated function, use CRM_Core_PseudoConstant::getLabel', array('civi.tag' => 'deprecated')); if (empty($groupName) || empty($value) ) { @@ -395,6 +396,8 @@ WHERE v.option_group_id = g.id return NULL; } + Civi::log()->warning('Deprecated function, use CRM_Core_PseudoConstant::getKey', array('civi.tag' => 'deprecated')); + $query = " SELECT v.label as label ,v.{$valueField} as value FROM civicrm_option_value v, -- 2.25.1