Tels wrote:
Here is a snippet from DynamicPageList2:
// The callback function for converting the input text to HTML output
function DynamicPageList2( $input ) {
...
global $wgTitle;
global $wgOut;
$ts = mktime();
$now = gmdate("YmdHis", $ts + 60);
$ns = $wgTitle->getNamespace();
$ti = wfStrencode($wgTitle->getDBkey());
... [snip]
$wgOut->addMeta("http:Pragma", "no-cache");
...
Please don't use $wgTitle in parser hook functions, it will break the job queue, and
anything else
that wants to parse more than one article. runJobs.php is set up to die with a backtrace
if anyone
attempts it. Instead, take a parser object as the third parameter, and use the
$parser->mTitle
member variable. Like this:
function DynamicPageList2( $input, $params, &$parser ) {
...
$ns = $parser->mTitle->getNamespace();
...
As Brion points out, using $wgOut won't work either, because data sent to $wgOut
won't be saved in
the parser cache. That's why all data generated in parser hooks needs to find its way
into the
ParserOutput object. Put an array of head items there, have the parser hook add one, maybe
via an
accessor in Parser. Then have OutputPage copy those items to itself in
OutputPage::addParserOutputNoText(). Then it will all work with the parser cache.
-- Tim Staring