Last modified: 2012-12-26 17:01:39 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 T42664, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 40664 - Unable to get template arguments through API
Unable to get template arguments through API
Status: NEW
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.20.x
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-01 17:31 UTC by Chris Down
Modified: 2012-12-26 17:01 UTC (History)
6 users (show)

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


Attachments

Description Chris Down 2012-10-01 17:31:17 UTC
Currently it is very difficult to parse templates externally. For example, if there is a template on a page with {{bots|deny=foo}}, a query to the "templates" prop shows that the "bots" template is on the page, but there is no way to get its attributes (both args and kwargs).

As such, it would be nice to have some API call where you both get the templates on a page and their attributes. As far as I can see this isn't currently implemented (apologies if I've missed it).
Comment 1 Chris Down 2012-10-01 17:33:36 UTC
I should mention that the reason that this is particularly difficult is because the ability to nest templates probably requires a CFG to properly parse them without this. It would be much easier just to be able to get this from the API.
Comment 2 Dereckson 2012-10-01 19:20:02 UTC
[ Confirming bug: valid feature request. ]
Comment 3 db [inactive,noenotif] 2012-10-01 19:30:04 UTC
The api allows you to get the (xml) parsetree of the parser with 
* action=parse&prop=wikitext&generatexml=
* action=expandtemplates
* prop=revisions&rvprop=content&generatexml=
Comment 4 Chris Down 2012-10-01 19:49:51 UTC
(In reply to comment #3)
> The api allows you to get the (xml) parsetree of the parser with 
> * action=parse&prop=wikitext&generatexml=
> * action=expandtemplates
> * prop=revisions&rvprop=content&generatexml=

Doesn't seem to work for me. I just get "Unrecognized value for parameter 'prop': revisions".
Comment 5 db [inactive,noenotif] 2012-10-01 19:59:36 UTC
prop is part of action=query and it was rvgeneratexml= (my comment should only be a hint to the doc http://en.wikipedia.org/w/api.php), but see the query for the parse tree:

http://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&
prop=revisions&rvprop=content&rvgeneratexml=

You can also use Special:ExpandTemplates (has to check a option) to see the parse tree, maybe that is human readable and easy to understand the parse tree for various input.
Comment 6 Chris Down 2012-10-01 20:20:18 UTC
I'm not seeing how having the XML parse tree helps this situation, unless I'm missing something. Even with Special:ExpandTemplates and the example that I gave, there would be no indication of the content of the arguments being passed.

In case I am not being clear enough about what I am requesting, the sort of exchange I'm looking for would be something like this:

Input:

    ...&title=Foo

The content on page Foo is the following:

    xxx{{wibble|bar|baz=qux}}yyy{{a|b|c=d}}

Output:

    <template title="wibble">
        <arg id=1>bar</arg>
        <arg title="baz">qux</arg>
    </template>
    <template title="a">
        <arg id=1>b</arg>
        <arg title="c">d</arg>
    </template>
Comment 7 db [inactive,noenotif] 2012-10-02 17:32:28 UTC
Yes, that is not so easy to use, but it contains the information:

Parse tree: (pretty printed by me)

<root>
 xxx
 <template>
  <title>wibble</title>
  <part><name index="1"/><value>bar</value></part>
  <part><name>baz</name>=<value>qux</value></part>
 </template>
 yyy
 <template>
  <title>a</title>
  <part><name index="1"/><value>b</value></part>
  <part><name>c</name>=<value>d</value></part>
 </template>
</root>

You have the name and the values of the template.
Only as alternative.

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


Navigation
Links