add redirect target value on page info (ApiQueryInfo)
Open, LowPublic

Description

It would be nice to get the redirect target as info from api when querying a redirect page.

At the current wmf live version you have to parse the page content for getting the correct redirect target. That should be unnecessary in future because of T30952.
But you still have to make two api requests (without and with redirect-Parameter) if you are also interested in informations about the redirect page. (E.g. if it's a staticredirect using page=pageprops).

It would be much easier if the redirect target information is also included in the page information when querying a page that is a redirect.

My suggestion would be that prop=info should contain this information in its redirect value. At the moment redirect="" is returned. This could be changed to redirect="iw:targetpage#anker", a combination of interwiki, fulltitle and fragment (splitting is not needed).

This shouldn't break existing tools because at the moment only the existence of this redirect attribute is tested and the value is ignored.


Version: unspecified
Severity: enhancement

Details

Reference
bz29115
bzimport raised the priority of this task from to Low.
bzimport set Reference to bz29115.
bzimport added a subscriber: Unknown Object (MLST).
Merl created this task.May 23 2011, 1:25 PM

Because of the extra query (and possibly parsing the redirect if there is no entry in the table) required, this should be an optional inprop that's disabled by default.

Merl added a comment.May 23 2011, 3:32 PM

Extra option is ok, but this extra query must only be executed if $this->pageIsRedir is true.

Commited gerrit 34977

successfully merged

Reedy added a comment.Dec 12 2012, 9:54 PM

Reverted in https://gerrit.wikimedia.org/r/#/c/38434/

Causing a lot of API OOMs on commonswiki

No idea, why this change causes OOM

Have you more information?
Which query was used

  • the new prop=info&inprop=redirecttargets
  • or existing &redirects of action=query

because both sharing code here.

Reedy added a comment.Dec 13 2012, 6:35 PM

(In reply to comment #6)

No idea, why this change causes OOM

Have you more information?
Which query was used

  • the new prop=info&inprop=redirecttargets
  • or existing &redirects of action=query because both sharing code here.

We don't have a url...

<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP Stack trace:
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 1. {main}() /usr/local/apache/common-local/live-1.5/api.php:0
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 2. require() /usr/local/apache/common-local/live-1.5/api.php:3
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 3. ApiMain->execute() /usr/local/apache/common-local/php-1.21wmf6/api.php:77
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 4. ApiMain->executeActionWithErrorHandling() /usr/local/apache/common-local/php-1.21wmf6/includes/api/ApiMain.php:349
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 5. ApiMain->executeAction() /usr/local/apache/common-local/php-1.21wmf6/includes/api/ApiMain.php:372
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 6. ApiQuery->execute() /usr/local/apache/common-local/php-1.21wmf6/includes/api/ApiMain.php:825
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 7. ApiPageSet->execute() /usr/local/apache/common-local/php-1.21wmf6/includes/api/ApiQuery.php:312
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 8. ApiPageSet->initFromTitles($titles = array (0 => 'File:Canadian Land Forces Command Badge.svg')) /usr/local/apache/common-local/php-1.21wmf6/includes/api/ApiPageSet.php:303
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 9. ApiPageSet->resolvePendingRedirects() /usr/local/apache/common-local/php-1.21wmf6/includes/api/ApiPageSet.php:432
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 10. ApiPageSet->getRedirectTargets() /usr/local/apache/common-local/php-1.21wmf6/includes/api/ApiPageSet.php:597
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 11. ApiPageSet->resolveIdsToRedirectTargets($redirectIDs = array (0 => 16128102), $profileDB = 'profileDB') /usr/local/apache/common-local/php-1.21wmf6/includes/api/ApiPageSet.php:627
<binasher> Dec 12 21:44:38 10.0.2.218 apache2[9189]: PHP 12. Title::makeTitle($ns = '6', $title = 'Canadian_Army_Badge.svg', $fragment = '', $interwiki = '') /usr/local/apache/common-local/php-1.21wmf6/includes/api/ApiPageSet.php:682

In most cases, it was OOMing in the Title::makeTitle() call

  • Bug 50981 has been marked as a duplicate of this bug. ***

Would be great to be somehow able to reproduce the bug and get more details. Do we have a test/dev instance working against the commons DB?

Now a prop=redirects module exists (goes live with 1.23wmf16), which maybe can help here, because it shows all redirects to a page:

https://www.mediawiki.org/w/api.php?action=query&titles=MediaWiki&prop=redirects&rdlimit=100

You can also use it as a generator to get information about the redirects:

https://www.mediawiki.org/w/api.php?action=query&titles=MediaWiki&generator=redirects&grdlimit=100&prop=pageprops

It is also possible to use it with &redirects=

https://www.mediawiki.org/w/api.php?action=query&titles=Main%20Page&prop=redirects&rdlimit=100&redirects=

Using it with generator and redirects= looks not very helpful:

https://www.mediawiki.org/w/api.php?action=query&titles=Main%20Page&generator=redirects&grdlimit=100&redirects=&prop=pageprops

because the redirects also resolved for the titles of the generator and not only of the query action. Not sure, if that is a feature or not.

jayvdb updated the task description. (Show Details)Jul 15 2015, 2:17 AM
jayvdb set Security to None.

Reading through the history here, I'm a little confused why this task is still unresolved... we should either implement this feature again (this task can probably be marked Easy and picked up fairly quickly) or we should close this task.

Given Umherirrender's comment, it's not immediately clear to me whether this feature is still needed. However, once that decision has been made (@Anomie, @Catrope, or @Reedy, thoughts?), resolving this task one way or another should be pretty quick and painless, I think.

The feature would probably still be useful. You can get the target by
passing the titles to action=query&redirects=1 (no prop modules needed),
but it's a bit awkward if you're also wanting other info about the redirect
itself.

prop=redirects is "what redirects here", not "where does this redirect to".

The feature would probably still be useful. You can get the target by
passing the titles to action=query&redirects=1 (no prop modules needed),
but it's a bit awkward if you're also wanting other info about the redirect
itself.

Cool, thanks for the quick feedback.

As far as I know, a modernized version of the approach taken in https://gerrit.wikimedia.org/r/34977 would be fine here. I guess we just need to make sure there's decent test coverage surrounding files/SVGs or something (given the previous out-of-memory errors)?

TTO added a subscriber: TTO.Aug 10 2015, 3:59 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 10 2015, 3:59 AM

I find this info useful as I do not need to parse the wikitext to see where an item redirects to (see T143200).

I think this functionality fits in the "info" [1] API. Something like a "redirecttitle" maybe?

https://en.wikipedia.org/w/api.php?action=help&modules=query%2Binfo

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptAug 17 2016, 2:18 PM

I think this functionality fits in the "info" [1] API. Something like a "redirecttitle" maybe?

https://en.wikipedia.org/w/api.php?action=query&titles=Main%20page&prop=info&redirects provides both info and the redirect target.
Am I misunderstanding something?

Anomie added a comment.EditedDec 21 2016, 7:48 PM

I think this functionality fits in the "info" [1] API. Something like a "redirecttitle" maybe?

https://en.wikipedia.org/w/api.php?action=query&titles=Main%20page&prop=info&redirects provides both info and the redirect target.
Am I misunderstanding something?

It provides info for the target of the redirect rather than the redirect itself.

For a slightly clearer example, https://en.wikipedia.org/w/api.php?action=query&titles=Foo&prop=info&redirects provides info about the target page (Foobar) rather than info about the redirect Foo.