From aaee3df07467f36dd21b2bfdb50ac93031ebbb53 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Fri, 24 Jul 2009 04:45:29 +0000 Subject: [PATCH] outputlib: debugging message was not being displayed when you forgot print_footer. --- lib/outputlib.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/outputlib.php b/lib/outputlib.php index b0ed1c95f35..1b55468f1b7 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -1574,6 +1574,16 @@ class xhtml_container_stack { * closes, so we can output helpful error messages when there is a mismatch. */ protected $log = array(); + /** + * Store whether we are developer debug mode. We need this in several places + * including in the destructor where we may no thave access to $CFG. + * @var boolean + */ + protected $isdebugging; + + public function __construct() { + $this->isdebugging = debugging('', DEBUG_DEVELOPER); + } /** * Push the close HTML for a recently opened container onto the stack. @@ -1586,7 +1596,7 @@ class xhtml_container_stack { $container = new stdClass; $container->type = $type; $container->closehtml = $closehtml; - if (debugging('', DEBUG_DEVELOPER)) { + if ($this->isdebugging) { $this->log('Open', $type); } array_push($this->opencontainers, $container); @@ -1613,7 +1623,7 @@ class xhtml_container_stack { '). This suggests there is a nesting problem.

' . $this->output_log(), DEBUG_DEVELOPER); } - if (debugging('', DEBUG_DEVELOPER)) { + if ($this->isdebugging) { $this->log('Close', $type); } return $container->closehtml; @@ -1661,8 +1671,12 @@ class xhtml_container_stack { return; } - debugging('

Some containers were left open. This suggests there is a nesting problem.

' . - $this->output_log(), DEBUG_DEVELOPER); + // It seems you cannot rely on $CFG, and hence the debugging function here, + // becuase $CFG may be destroyed before this object is. + if ($this->isdebugging) { + echo '

Some containers were left open. This suggests there is a nesting problem.

' . + $this->output_log() . '
'; + } echo $this->pop_all_but_last(); $container = array_pop($this->opencontainers); echo $container->closehtml;