Last modified: 2010-05-15 16:03:51 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 13408 - ParserAfterTidy hook passes only one short line in $text
ParserAfterTidy hook passes only one short line in $text
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2008-03-17 22:25 UTC by James Paige
Modified: 2010-05-15 16:03 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description James Paige 2008-03-17 22:25:00 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) {

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?
Comment 1 Brion Vibber 2008-03-17 22:45:16 UTC
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.
Comment 2 James Paige 2008-03-17 22:58:58 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.