From 44f27e4123556f14fd5f1da22b8606b0cb528534 Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 13 Jun 2009 16:07:14 +0000 Subject: [PATCH] MDL-14990 pritning of backtrace does not rely on $CFG any more and can be used from destructors --- lib/weblib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 7b134088a3..26feb67dda 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -7036,8 +7036,9 @@ function debugging($message='', $level=DEBUG_NORMAL, $backtrace=null) { * @return string|bool Depending on $return */ function print_backtrace($callers, $plaintext=false, $return=false) { - global $CFG; - + // do not use $CFG->dirroot because it might not be available in desctructors + $dirroot = dirname(dirname(__FILE__)); + if (empty($callers)) { if ($return) { return ''; @@ -7052,10 +7053,10 @@ function print_backtrace($callers, $plaintext=false, $return=false) { $caller['line'] = '?'; // probably call_user_func() } if (!isset($caller['file'])) { - $caller['file'] = $CFG->dirroot.'/unknownfile'; // probably call_user_func() + $caller['file'] = 'unknownfile'; // probably call_user_func() } $from .= $plaintext ? '* ' : '
  • '; - $from .= 'line ' . $caller['line'] . ' of ' . substr($caller['file'], strlen($CFG->dirroot) + 1); + $from .= 'line ' . $caller['line'] . ' of ' . str_replace($dirroot, '', $caller['file']); if (isset($caller['function'])) { $from .= ': call to '; if (isset($caller['class'])) { -- 2.39.5