From 5a0aaa1e41dc0172769945c8d2497bf7853eae99 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 8 Jun 2020 12:49:30 +0100 Subject: [PATCH] Support passing old method name into deprecatedFunctionWarning --- CRM/Core/Error.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index 573cd4739c..808375d293 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -1033,14 +1033,19 @@ class CRM_Core_Error extends PEAR_ErrorStack { /** * Output a deprecated function warning to log file. Deprecated class:function is automatically generated from calling function. * - * @param $newMethod + * @param string $newMethod * description of new method (eg. "buildOptions() method in the appropriate BAO object"). + * @param string $oldMethod + * optional description of old method (if not the calling method). eg. CRM_MyClass::myOldMethodToGetTheOptions() */ - public static function deprecatedFunctionWarning($newMethod) { - $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); - $callerFunction = $dbt[1]['function'] ?? NULL; - $callerClass = $dbt[1]['class'] ?? NULL; - Civi::log()->warning("Deprecated function $callerClass::$callerFunction, use $newMethod.", ['civi.tag' => 'deprecated']); + public static function deprecatedFunctionWarning($newMethod, $oldMethod = NULL) { + if (!$oldMethod) { + $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + $callerFunction = $dbt[1]['function'] ?? NULL; + $callerClass = $dbt[1]['class'] ?? NULL; + $oldMethod = "{$callerClass}::{$callerFunction}"; + } + Civi::log()->warning("Deprecated function $oldMethod, use $newMethod.", ['civi.tag' => 'deprecated']); } } -- 2.25.1