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

Merge pull request #20719 from mattwire/deprecatedwarningcaller

Add calling function to deprecatedWarning log message
parents 392c3dcb f87a8e30
Branches
Tags
No related merge requests found
......@@ -38,6 +38,8 @@ class CRM_ACL_API {
*
* @return bool
* true if yes, else false
*
* @deprecated
*/
public static function check($str, $contactID = NULL) {
\CRM_Core_Error::deprecatedWarning(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated.');
......
......@@ -188,6 +188,8 @@ SELECT acl.*
* @param int $contactID
*
* @return bool
*
* @deprecated
*/
public static function check($str, $contactID) {
\CRM_Core_Error::deprecatedWarning(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated.');
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment