Skip to content
Snippets Groups Projects
Unverified Commit 49b2c76f authored by Eileen McNaughton's avatar Eileen McNaughton Committed by GitHub
Browse files

Merge pull request #17552 from mattwire/deprecatedfunctionwarning

Support passing old method name into deprecatedFunctionWarning
parents d1f859b2 5a0aaa1e
Branches
Tags
No related merge requests found
......@@ -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']);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment