(bug 31849) API imageinfo correctly handle redirects
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 26 Dec 2012 15:40:43 +0000 (10:40 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 22 Jan 2013 19:31:38 +0000 (14:31 -0500)
commit6a9ec236126ba82d6f8e0984a7ef1fd58a68aa3d
treeca797828aeeb2f08e4c675477b48084fa9f2fac1
parente45d154faa576f832f5782411182c58b399f392b
(bug 31849) API imageinfo correctly handle redirects

RepoGroup::singleton()->findFiles() returns an associative array mapping
the redirect *target* to the image object; the image object refers back
to the original title queried.

If a redirect and its target are both queried,
RepoGroup::singleton()->findFiles() will return an entry for the target
title only, mapping to an image object that may have getOriginalTitle()
returning the redirect. If this happens, prop=imageinfo will never see
an entry for which getOriginalTitle()->isRedirect() is false and so will
not return any information about the image.

The fix is to ignore getOriginalTitle() entirely. Instead, we just go
through each of our queried titles and see if we got any result back.

Note this automatically handles a "redirects=1" query correctly, since
in that case any local redirect will already have been followed before
we ever got the list of titles to query.

Change-Id: I0b2982901e2dc4491e2933291fd97697b2a622a9
RELEASE-NOTES-1.21
includes/api/ApiQueryImageInfo.php