* 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.
$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);
'). This suggests there is a nesting problem.</p>' .
$this->output_log(), DEBUG_DEVELOPER);
}
- if (debugging('', DEBUG_DEVELOPER)) {
+ if ($this->isdebugging) {
$this->log('Close', $type);
}
return $container->closehtml;
return;
}
- debugging('<p>Some containers were left open. This suggests there is a nesting problem.</p>' .
- $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 '<div class="notifytiny"><p>Some containers were left open. This suggests there is a nesting problem.</p>' .
+ $this->output_log() . '</div>';
+ }
echo $this->pop_all_but_last();
$container = array_pop($this->opencontainers);
echo $container->closehtml;