Page MenuHomePhabricator

Index page not recorded as a dependency when using ProofreadPages
Closed, ResolvedPublic

Description

Author: ralf_wikimedia

Description:
I'm trying to get the collection extension working on wikisource. I've found the following problem:

mediawiki's api.php does not return the index pages used for rendering the pages tags.

e.g. the following snippet on http://de.wikisource.org/

<pages index="Beim Bau der chinesischen Mauer" from="Kafka Beim Bau der Chinesischen Mauer 074.jpg" to="Kafka Beim Bau der Chinesischen Mauer 076.jpg" />

uses the page http://de.wikisource.org/wiki/Index:Beim_Bau_der_chinesischen_Mauer

which isn't returned by api.php as one of the pages used.


Version: unspecified
Severity: blocker

Details

Reference
bz21136

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:56 PM
bzimport added a project: ProofreadPage.
bzimport set Reference to bz21136.

thomasV1 wrote:

that is normal.
this bit of code does not use the index page, but subpages linked from the index.
afaik these subpages should be counted as dependencies.

ralf_wikimedia wrote:

(In reply to comment #1)

that is normal.
this bit of code does not use the index page, but subpages linked from the
index.

I disagree. If you delete that index page, the above snippet renders as an error message.
Note that when expanding a #ifexist template as in "{{#ifexist:Foo|yes|no}}", the page "Foo" is also returned as a dependency (if it exists).

afaik these subpages should be counted as dependencies.

I think the subpages are already returned as dependencies (but I might be wrong, don't quite remember it)

thomasV1 wrote:

I assume you are talking about the list of templates returned by ?action=parse (please confirm)

The pages are returned as dependencies, and the index page is not in the list of templates.

Is this the reason why the <pages /> tag is not evaluated in the Collection extension ?

ralf_wikimedia wrote:

(In reply to comment #3)

I assume you are talking about the list of templates returned by ?action=parse
(please confirm)

Here is the exact api.php call we make:
,----

% curl 'http://de.wikisource.org/w/api.php?redirects=1&tllimit=500&format=json&rvprop=ids&prop=revisionstemplatesimages&titles=Benutzer:Schmir&action=query&imlimit=500'
{"query":{"pages":{"194920":{"pageid":194920,"ns":2,"title":"Benutzer:Schmir","revisions":[{"revid":874475,"parentid":874468}],"templates":[{"ns":8,"title":"MediaWiki:Proofreadpage pagenum template"},{"ns":10,"title":"Vorlage:Center"},{"ns":102,"title":"Seite:Kafka Beim Bau der Chinesischen Mauer 074.jpg"},{"ns":102,"title":"Seite:Kafka Beim Bau der Chinesischen Mauer 075.jpg"},{"ns":102,"title":"Seite:Kafka Beim Bau der Chinesischen Mauer 076.jpg"}]}}}}

`----

This is for my user page which contains the following:

,----

<pages index="Beim Bau der chinesischen Mauer" from="Kafka Beim Bau der Chinesischen Mauer 074.jpg" to="Kafka Beim Bau der Chinesischen Mauer 076.jpg" />

`----

The pages are returned as dependencies, and the index page is not in the list
of templates.

Is this the reason why the <pages /> tag is not evaluated in the Collection
extension ?

It's the reason why we can't even start to implement it.

thomasV1 wrote:

I understand that I should try to include the index page as a dependency, just as in the #ifexist parser hook.

So I looked at #ifexist. Here is an example :

http://fr.wikisource.org/wiki/Utilisateur:ThomasV/test2

And here is the corresponding API request :

http://fr.wikisource.org/w/api.php?redirects=1&tllimit=500&format=jsonfm&rvprop=ids&prop=revisions|templates|images&titles=User:ThomasV/test2&action=query&imlimit=500

As you can see, the API does not return the first part of the #ifexist as a dependency. So for me it is not clear what you want me to do...

thomasV1 wrote:

...although it is returned as a "link" if you add "links" to your API request :

http://fr.wikisource.org/w/api.php?redirects=1&tllimit=500&format=jsonfm&rvprop=ids&prop=revisions|templates|links&titles=User:ThomasV/test2&action=query&imlimit=500

...but you are not doing that ; you seem to be requesting templates, not links.

ralf_wikimedia wrote:

yes, you're right about the current #ifexist behaviour. I probably was mistaken about that (or the behaviour changed). I am very sorry about that.

Anyway, the index page is being used to generate the output just like all the other pages, which are returned as a dependency.

thomasV1 wrote:

"As a dependency" is not clear. Do you need the index page to be returned as a link or as a template ? here are two patches : the first one returns it as a link, the second one as a template. Please tell me which one you need.

Index: ProofreadPage.php

  • ProofreadPage.php (révision 67856)

+++ ProofreadPage.php (copie de travail)
@@ -745,6 +745,7 @@

	if( ! $index_title || ! $index_title->exists() ) {
		return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_index' ) . '</strong>';
	}

+ $parser->mOutput->addLink( $index_title, $index_title->getArticleID() );

	$out = '';

Index: ProofreadPage.php

  • ProofreadPage.php (révision 68350)

+++ ProofreadPage.php (copie de travail)
@@ -745,6 +745,7 @@

	if( ! $index_title || ! $index_title->exists() ) {
		return '<strong class="error">' . wfMsgForContent( 'proofreadpage_nosuch_index' ) . '</strong>';
	}

+ $parser->mOutput->addTemplate( $index_title, $index_title->getArticleID(), $index_title->getLatestRevID() );

	$out = '';

ralf_wikimedia wrote:

we would need the second one

thomasV1 wrote:

commited, see r68394