Page MenuHomePhabricator

Bad Behavior extension called multiple times during page render
Closed, InvalidPublic


Author: spambox

I've reported this bug to the author of the Bad Behavior extension and he's
indicated that it only appears in 1.7.1 to his knowledge, and seems to be
related to the hook which calls Bad Behavior being called multiple times during
the generation of certain pages.

The symptoms are excessive whitespace in certain pages, particluarly
Special:Recentchanges and the edit page. This is caused by spurious insertion
of <p> tags into the code. Associated with insertions of whitespace or <p> tags
is a Bad Behavior runtime comment, indicating that the extension is being run
multiple times for certain page renders. The comments are not always associated
with insertion of HTML elements which mess up the page, however. Bad Behavior
comments appear at other places in the source without associated whitespace.

This behavior has been noted on two MediaWiki installations running 1.7.1 and
Bad Behavior 2.0.5 and 2.0.6. They can be found at
and . The author insists that the bug must be in
MediaWiki so I am reporting it here.

Version: 1.7.x
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:23 PM
bzimport set Reference to bz7424.
bzimport added a subscriber: Unknown Object (MLST).

Sounds like a bug in the extension, which we don't have and didn't write. It's
probably making incorrect assumptions, and making incorrect output.

spambox wrote:

Even though this bug is (currently) closed, I'd like to point out that the
function in Bad Behavior 2 which outputs the timing comments associated with the
spurious whitespace is called by hooking to ParserAfterTidy. So my uneducated
guess is that there might be a problem with ParserAfterTidy.


$wgHooks['ParserAfterTidy'][] = 'bb2_mediawiki_timer';


function bb2_mediawiki_timer(&$parser, &$text) {
global $bb2_timer_total;
$text = "<!-- Bad Behavior " . BB2_VERSION . " run time: " . number_format(1000

  • $bb2_timer_total, 3) . " ms -->\n" . $text;


It doesn't explain the apparent insertion of <p> tags, but this HTML comment is
being added multiple times within the rendered source of the page.