From: Matthew Wire Date: Mon, 8 Jun 2020 11:49:30 +0000 (+0100) Subject: Support passing old method name into deprecatedFunctionWarning X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5a0aaa1e41dc0172769945c8d2497bf7853eae99;p=civicrm-core.git Support passing old method name into deprecatedFunctionWarning --- 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']); } }