I wrote an extension that hooks OutputPageBeforeHTML and runs on every
page load, but intermittently, $wgParser->getTitle() returns NULL.
Anybody know why?
Here's the weirdest part: if you edit an article in IE and save it, then
when the article redisplays, $wgParser->getTitle() returns NULL. But if
you edit in Firefox and save it, $wgParser->getTitle() returns the
correct Title object.
Any explanations? Bug? Or did I write something wrong?
The minimal code looks like:
<?php
// Run on every page load
new MyClass();
class MyClass {
public function __construct() {
global $wgHooks;
$wgHooks['OutputPageBeforeHTML'][] = array($this, 'myMethod');
}
// Hook function
function myMethod($parserOutput, &$text) {
global $wgParser;
$title = $wgParser->getTitle();
if ($title) {
echo "OK";
} else {
echo "bug";
}
}
}
DanB
Show replies by date