Last modified: 2014-07-18 18:18:34 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 T48115, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 46115 - Template expansion via API fails
Template expansion via API fails
Status: NEW
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.21.x
All All
: High critical with 3 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 48872 50090 53260 (view as bug list)
Depends on:
Blocks: 44552 47818
  Show dependency treegraph
 
Reported: 2013-03-14 14:01 UTC by Volker Haas
Modified: 2014-07-18 18:18 UTC (History)
11 users (show)

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


Attachments

Description Volker Haas 2013-03-14 14:01:07 UTC
The problem is that the expandtemplates API call returns with some unexpanded
templates:

Minimal Example:
http://en.wikipedia.org/w/index.php?title=User:Volker.haas/TemplateExpansion&oldid=544039610


API Call (without revision info of article...):
https://en.wikipedia.org/w/api.php?action=expandtemplates&format=jsonfm&text={{User:Volker.haas/TemplateExpansion}}

Result:
>{
>	"expandtemplates": {
>		"*": "blub<ref>{{Structurae|id=s0015184|title=Padma >Bridge|nolink=1}}, [[Padma Bridge|Report on the official hearing on construction >progress]]<\/ref>\n\n== References ==\n<div class=\"reflist >references->column-count references-column-count-2\" style=\"-moz-column-count: >2; -webkit-column-count: 2; column-count: 2; list-style-type: decimal;\">\n<references group=\"\"><\/references><\/div>"
>	}
>}

This issue is criticial for the PDF rendering software (Extension:Collection and mwlib), since it now uses the API for expanding templates
Comment 1 Antoine "hashar" Musso (WMF) 2013-03-14 14:10:26 UTC
Using the ApiSandbox:

http://en.wikipedia.org/wiki/Special:ApiSandbox#action=expandtemplates&format=json&text=%7B%7BUser%3AVolker.haas%2FTemplateExpansion%7D%7D

The result shows up {{cite web...  I guess there is no recursion.
Comment 2 Antoine "hashar" Musso (WMF) 2013-03-14 14:13:13 UTC
With action=parse&prop=text&page=User:Voker.haas/TemplateExpansion

http://en.wikipedia.org/wiki/Special:ApiSandbox#action=parse&format=json&page=User%3AVolker.haas%2FTemplateExpansion&prop=text

So I guess you want to use action=parse&prop=text&page=  instead of action=expandtemplate.
Comment 3 Ralf Schmitt 2013-03-15 13:22:29 UTC
Does the above call expand templates and give me mediawiki markup? If not, that's not what we want...
Comment 4 Antoine "hashar" Musso (WMF) 2013-03-15 14:16:17 UTC
Ah no, that render them :-] Sorry.
Comment 5 Helder 2013-03-16 12:53:35 UTC
Compare this with the behavior described on bug 28616.
Comment 7 Brad Jorsch 2013-04-16 21:00:39 UTC
The problem is that "expandtemplates" is a bit of a hack: it half-parses the wikitext to get new wikitext. But this half-parsing can't include calling tag hooks, because the tag hook returns HTML rather than wikitext. And it can't necessarily parse the text passed to the tag hook, because the tag hook might do almost anything with it (e.g. <syntaxhighlight> doesn't expand any templates, <ref> does, and it's theoretically possible to create a tag hook that would run inline Lua code or the like. So it just outputs the tag contents as-is.

It sometimes breaks in other ways, too. Consider, for example, what it does to something like "{{#tag:ref|Ref A<ref>Ref B</ref>}}".

Bug 28616 is similar: Special:ExpandTemplates half-parses the wikitext, and then parsed the half-parsed wikitext. This two-step parse can give different results.
Comment 8 Ralf Schmitt 2013-08-23 08:42:19 UTC
*** Bug 50090 has been marked as a duplicate of this bug. ***
Comment 9 Ralf Schmitt 2013-08-23 08:43:14 UTC
*** Bug 48872 has been marked as a duplicate of this bug. ***
Comment 10 This, that and the other (TTO) 2013-08-25 10:39:01 UTC
*** Bug 53260 has been marked as a duplicate of this bug. ***

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


Navigation
Links