🐛 Fix \DeprecatedCallsLog::NotifyDeprecatedPhpMethod log message

This was bringed by #193
The stack trace wasn't used correctly :/ This is now fixed !

Sample message for deprecated PHP method call :
`2021-04-13 15:31:47 | Warning | Call to WebPage:outputCollapsibleSectionInit in  C:\...\itop-dev\sources\application\WebPage\AjaxPage.php#L170 (AjaxPage::output) | deprecated-php-method`

Log message for deprecated PHP file remains the same :
`2021-04-13 10:31:12 | Warning | C:\...\itop-dev\sources\application\WebPage\WebPage.php L32 including/requiring C:\...\itop-dev\core\coreexception.class.inc.php : Classes were moved to /application/exceptions | deprecated-file`
This commit is contained in:
Pierre Goiffon
2021-04-13 15:37:21 +02:00
parent 2a90557782
commit 7f4ef12c04

View File

@@ -873,14 +873,18 @@ class DeprecatedCallsLog extends LogAPI
}
$aStack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
$sCallerObject = $aStack[2]['class'];
$sCallerMethod = $aStack[2]['function'];
$sCallerLine = $aStack[2]['line'];
$sDeprecatedObject = $aStack[1]['class'];
$sDeprecatedMethod = $aStack[1]['function'];
$sCallerFile = $aStack[1]['file'];
$sCallerLine = $aStack[1]['line'];
$sMessage = "Call to {$sDeprecatedObject}::{$sDeprecatedMethod} in {$sCallerFile}#L{$sCallerLine}";
$sMessage = "{$sCallerObject}::{$sCallerMethod} L{$sCallerLine} calling {$sDeprecatedObject}:{$sDeprecatedMethod}";
if (array_key_exists(2, $aStack)) {
$sCallerObject = $aStack[2]['class'];
$sCallerMethod = $aStack[2]['function'];
$sMessage .= " ({$sCallerObject}::{$sCallerMethod})";
}
if (!is_null($sAdditionalMessage)) {
$sMessage .= ' : '.$sAdditionalMessage;