* (bug 23563) Old skins now support $wgUploadNavigationUrl and take into account upload rights.
* (bug 1347) Render \phi in math using images, in order to create consistent and correct render results.
* (bug 16573) Render \epsilon in math using images, in order to create consistent and correct render results.
+* (bug 22541) Support image redirects when using ForeignAPIRepo
=== API changes in 1.17 ===
* (bug 22738) Allow filtering by action type on query=logevent
}
static function newFromTitle( $title, $repo ) {
- $info = $repo->getImageInfo( $title );
- if( $info ) {
- return new ForeignAPIFile( $title, $repo, $info, true );
+ $data = $repo->fetchImageQuery( array(
+ 'titles' => 'File:' . $title->getText(),
+ 'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime',
+ 'prop' => 'imageinfo' ) );
+
+ $info = $repo->getImageInfo( $data );
+
+ if( $data && $info) {
+ if( isset( $data['query']['redirects'][0] ) ) {
+ $newtitle = Title::newFromText( $data['query']['redirects'][0]['to']);
+ $img = new ForeignAPIFile( $newtitle, $repo, $info, true );
+ if( $img ) $img->redirectedFrom( $title->getDBkey() );
+ } else {
+ $img = new ForeignAPIFile( $title, $repo, $info, true );
+ }
+ return $img;
} else {
return null;
}
return false;
}
- protected function queryImage( $query ) {
- $data = $this->fetchImageQuery( $query );
-
- if( isset( $data['query']['pages'] ) ) {
- foreach( $data['query']['pages'] as $pageid => $info ) {
- if( isset( $info['imageinfo'][0] ) ) {
- return $info['imageinfo'][0];
- }
- }
- }
- return false;
- }
-
- protected function fetchImageQuery( $query ) {
+ function fetchImageQuery( $query ) {
global $wgMemc;
$url = $this->mApiBase .
array_merge( $query,
array(
'format' => 'json',
- 'action' => 'query' ) ) );
+ 'action' => 'query',
+ 'redirects' => 'true' ) ) );
if( !isset( $this->mQueryCache[$url] ) ) {
$key = $this->getLocalCacheKey( 'ForeignAPIRepo', 'Metadata', md5( $url ) );
return FormatJson::decode( $this->mQueryCache[$url], true );
}
- function getImageInfo( $title, $time = false ) {
- return $this->queryImage( array(
- 'titles' => 'Image:' . $title->getText(),
- 'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime',
- 'prop' => 'imageinfo' ) );
+ function getImageInfo( $data ) {
+ if( $data && isset( $data['query']['pages'] ) ) {
+ foreach( $data['query']['pages'] as $pageid => $info ) {
+ if( isset( $info['imageinfo'][0] ) ) {
+ return $info['imageinfo'][0];
+ }
+ }
+ }
+ return false;
}
function findBySha1( $hash ) {
}
function getThumbUrl( $name, $width=-1, $height=-1 ) {
- $info = $this->queryImage( array(
- 'titles' => 'Image:' . $name,
+ $data = $this->fetchImageQuery( array(
+ 'titles' => 'File:' . $name,
'iiprop' => 'url',
'iiurlwidth' => $width,
'iiurlheight' => $height,
'prop' => 'imageinfo' ) );
- if( $info && $info['thumburl'] ) {
+ $info = $this->getImageInfo( $data );
+
+ if( $data && $info && $info['thumburl'] ) {
wfDebug( __METHOD__ . " got remote thumb " . $info['thumburl'] . "\n" );
return $info['thumburl'];
} else {