From 0d8a21f6ef982427487cb335412b71f1b409207b Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 17 Jan 2023 16:29:25 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B05897=20-=20Improve=20deprecated=20logs?= =?UTF-8?q?=20relevance=20for=20PHP=20"trigger=5Fdeprecation"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/log.class.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/log.class.inc.php b/core/log.class.inc.php index 3a98b4f77..07d88fbe4 100644 --- a/core/log.class.inc.php +++ b/core/log.class.inc.php @@ -1110,7 +1110,12 @@ class DeprecatedCallsLog extends LogAPI } $aStack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4); - $iStackDeprecatedMethodLevel = 2; // level 0 = current method, level 1 = @trigger_error, level 2 = method containing the `trigger_error` call + $iStackDeprecatedMethodLevel = 2; // level 0 = current method, level 1 = @trigger_error, level 2 = method containing the `trigger_error` call (can be either 'trigger_deprecation' or the faulty method), level 3 = In some cases, method containing the 'trigger_deprecation' call + // In case current level is actually a 'trigger_deprecation' call, try to go one level further to get the real deprecated method + if (array_key_exists($iStackDeprecatedMethodLevel, $aStack) && ($aStack[$iStackDeprecatedMethodLevel]['function'] === 'trigger_deprecation') && array_key_exists($iStackDeprecatedMethodLevel + 1, $aStack)) { + $iStackDeprecatedMethodLevel++; + } + $sDeprecatedObject = $aStack[$iStackDeprecatedMethodLevel]['class']; $sDeprecatedMethod = $aStack[$iStackDeprecatedMethodLevel]['function']; if (($sDeprecatedObject === __CLASS__) && ($sDeprecatedMethod === 'Log')) {