Skip to content

Commit

Permalink
Support passing old method name into deprecatedFunctionWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Jun 8, 2020
1 parent 4de71a0 commit 5a0aaa1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions CRM/Core/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -1033,14 +1033,19 @@ public static function isAPIError($error, $type = CRM_Core_Error::FATAL_ERROR) {
/**
* 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']);
}

}
Expand Down

0 comments on commit 5a0aaa1

Please sign in to comment.