Last modified: 2010-05-15 16:03:51 UTC
I was trying to write an extension that adds a function to the ParserAfterTidy hook. It appears that the $text argument to this hook contains only a single tiny line from the bottom of the page, rather than the entire text of the page as expected. I wrote a function like this: function fnSectionIndenter(&$parser, &$text) { var_dump($text); die(); } and when I reloaded the page on my testing wiki, I got this output: string(45) " This page has been accessed 49 times. " What happened to the rest of the text of the page? Am I misunderstanding how this extension hook is intended to be used?
The rest of the text of the page was rendered previously, such as when it was last saved, and the output cached. Since it's not being rendered again, the parser and the parser's hooks are not running for it. You should never, ever, ever, ever assume that text run through the parser does any of the following: * is the article text * is the only text to be run through the parser * is parsed when it's displayed * is displayed when it's parsed Any and all of the above assumptions are usually false.
Ah, thank you for the clarifications. I dug deeper into the documentation, and I now understand that I can temporarily put $parser->disableCache(); at the beginning of my extension function to force something closer to the behavior I was expecting.