Page MenuHomePhabricator

API: add prop=headitems to action=parse
Closed, ResolvedPublic

Description

This is from wikitech-l (see URL): Extensions like SyntaxHighlight_GeSHi put generated styles or javascript into the page via ParserOutput->mHeadItems. These items should be made available through the API so gadgets like LivePreview can use them.


Version: 1.16.x
Severity: enhancement
URL: http://lists.wikimedia.org/pipermail/wikitech-l/2010-January/046242.html

Details

Reference
bz22061

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:55 PM
bzimport set Reference to bz22061.

Proposed patch: Add prop=headitems to ApiParse.php

Straightforward patch. Also added a getter function for ParserOutput->mHeadItems, which appeared to be missing.

attachment bug22061.patch ignored as obsolete

(In reply to comment #1)

Created an attachment (id=6942) [details]
Proposed patch: Add prop=headitems to ApiParse.php

Straightforward patch. Also added a getter function for
ParserOutput->mHeadItems, which appeared to be missing.

Patch looks OK except that it removes the (array) cast in OutputPage.php for no apparent reason.

(In reply to comment #2)

Patch looks OK except that it removes the (array) cast in OutputPage.php for no
apparent reason.

I'm pretty sure that the cast is not necessary there (since the var is initialised as array() and then only added to), but if you feel uncomfortable with it, of course just skip the change.

Assigning to me as per Roan on IRC

(In reply to comment #3)

I'm pretty sure that the cast is not necessary there (since the var is
initialised as array() and then only added to), but if you feel uncomfortable
with it, of course just skip the change.

FTR: The cast was added in r21055 (Apr 2007) to deal with old parsercache entries. I think we can safely assume that they're all gone by now :)

Created attachment 6952
Fixup post conflict from whitespace changes

Attached:

I'm gonna end up feeling thick here... But with that patch, what sort of things is it supposed to be outputting? As i've just got my test wiki, with literally nothing on it.

Did install Geshi..

I was also about to make a really thick comment, but then i realised what i was that issue was. ;)

Well, according to grep, ParserOutput::addHeadItem is used by the following extensions:

[[mw:Extension:CSS]] - test case: < http://localhost/test/api.php?action=parse&prop=text|headitems&text=%7B%7B%23css:%23content%20%7Bbackground-color:%23def;%7D%20%7D%7D >

[[mw:Extension:PageCSS]] (which is basically the same)

[[mw:Extension:SyntaxHighlight_GeSHi]] - test case: < http://localhost/test/api.php?action=parse&prop=text|headitems&text=%3Csource%20lang=javascript%3Evar%20foo%20=%20'bar';%3C/source%3E>

[[mw:Extension:SemanticForms]] and [[mw:Extension:SemanticMediaWiki]] (which I didn't test)