From f14f01a33b4dd20c11113fe40e3083b7ed396fd4 Mon Sep 17 00:00:00 2001 From: btongminh Date: Sat, 22 Dec 2012 16:36:16 +0100 Subject: [PATCH] (bug 36751) InstantCommons doesn't follow redirects This fixes r56837: now redirects are only skipped if the redirects query parameter is not set. This was presumably the intent of that commit, see https://www.mediawiki.org/wiki/Special:Code/MediaWiki/56837#code-comments Change-Id: I27485bba9fe196211baeeb84238e4a397c620a1d --- RELEASE-NOTES-1.21 | 1 + includes/api/ApiQueryImageInfo.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index 46d69d01b7..608d7bb65a 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -132,6 +132,7 @@ production. * (bug 27202) Add timestamp sort to list=allimages. * (bug 43137) Don't return the sha1 of revisions through the API if the content is revision-deleted +* ApiQueryImageInfo now also returns imageinfo for redirects. === Languages updated in 1.21 === diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 1933c7887d..2be33931ce 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -79,14 +79,15 @@ class ApiQueryImageInfo extends ApiQueryBase { } else { $images = RepoGroup::singleton()->findFiles( $titles ); } + $resolveRedirects = $this->getPageSet()->isResolvingRedirects(); foreach ( $images as $img ) { // Skip redirects - if ( $img->getOriginalTitle()->isRedirect() ) { + if ( $img->getOriginalTitle()->isRedirect() && !$resolveRedirects ) { continue; } $start = $skip ? $fromTimestamp : $params['start']; - $pageId = $pageIds[NS_FILE][ $img->getOriginalTitle()->getDBkey() ]; + $pageId = $pageIds[NS_FILE][ $img->getTitle()->getDBkey() ]; $fit = $result->addValue( array( 'query', 'pages', intval( $pageId ) ), -- 2.20.1