Page MenuHomePhabricator

Remove insertStripItem workarounds from parser function implementations
Open, Needs TriagePublic

Description

As documented in this page from 2007, it used to be the case that whitespace was added before parser function-generated HTML.

To work around this, instead of the straightforward:

function renderRawHTML( &$parser, $input='' ) {
    return array( $input, noparse => true, isHTML => true );
}

...extension authors instead wrote:

function renderRawHTML( &$parser, $input='' ) {
    return $parser->insertStripItem( $input, $parser->mStripState );
}

We'd like to reduce unnecessary usage of insertStripItem and the exposure of parser internal state from parser function implementations.

The bug this was working around was fixed by @SPQRobin in commit 84b8ca9801c0e1ad3bcd4c7d6d5d58c26a69d1b7 in May 2012 and first shipped in 1.20wmf9.

Some actions items (should eventually be made into sub-tasks):

  • Add a code to the core parser to warn or log if insertStripItem is called during a parser function invocation, which will help determine the extent of the issue.
  • Fix Extension:PageForms, where this pattern was discovered (already requires MW 1.21+)
  • Determine other extensions which might be using this pattern.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@cscott - thanks for letting me know about this. I just checked in a fix to Page Forms to remove all the calls to insertStripItem(). It looks like two more of my extensions, Cargo and Header Tabs, include the same hack and need to be modified also.

Change 469315 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/core@master] Hard deprecate insertStripItem inside a parser function implementation

https://gerrit.wikimedia.org/r/469315

Removing task assignee due to inactivity, as this open task has been assigned to the same person for more than two years (see the emails sent to the task assignee on Oct27 and Nov23). Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome.
(See https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator.)