Skip to content

Commit

Permalink
MDL-14990 pritning of backtrace does not rely on $CFG any more and ca…
Browse files Browse the repository at this point in the history
…n be used from destructors
  • Loading branch information
skodak committed Jun 13, 2009
1 parent b4154c2 commit 44f27e4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/weblib.php
Expand Up @@ -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 '';
Expand All @@ -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 ? '* ' : '<li>';
$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'])) {
Expand Down

0 comments on commit 44f27e4

Please sign in to comment.