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

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T15408, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 13408 - ParserAfterTidy hook passes only one short line in $text
ParserAfterTidy hook passes only one short line in $text
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.13.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  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: ---


Attachments

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) {
  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?
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.


Navigation
Links