From ee2c6cde728218b973c5018f588a3946d13b8fec Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 28 Jun 2021 09:43:02 +0100 Subject: [PATCH] Add calling function to deprecatedWarning log message --- CRM/Core/Error.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index 6c44df6261..a131be146a 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -1039,16 +1039,23 @@ class CRM_Core_Error extends PEAR_ErrorStack { $callerClass = $dbt[1]['class'] ?? NULL; $oldMethod = "{$callerClass}::{$callerFunction}"; } - self::deprecatedWarning("Deprecated function $oldMethod, use $newMethod."); + $message = "Deprecated function $oldMethod, use $newMethod."; + Civi::log()->warning($message, ['civi.tag' => 'deprecated']); + trigger_error($message, E_USER_DEPRECATED); } /** * Output a deprecated notice about a deprecated call path, rather than deprecating a whole function. + * * @param string $message */ public static function deprecatedWarning($message) { // Even though the tag is no longer used within the log() function, // \Civi\API\LogObserver instances may still be monitoring it. + $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); + $callerFunction = $dbt[2]['function'] ?? NULL; + $callerClass = $dbt[2]['class'] ?? NULL; + $message .= " Caller: {$callerClass}::{$callerFunction}"; Civi::log()->warning($message, ['civi.tag' => 'deprecated']); trigger_error($message, E_USER_DEPRECATED); } -- 2.25.1