From: Bryan Tong Minh Date: Thu, 8 May 2008 20:55:13 +0000 (+0000) Subject: * Move image page redirect checking to ImagePage. Should now also work on foreign... X-Git-Tag: 1.31.0-rc.0~47802 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=3611f529a88722cb81b819da87af4582de2cd479;p=lhc%2Fweb%2Fwiklou.git * Move image page redirect checking to ImagePage. Should now also work on foreign repos. * Changed File::getRedirected to return a DBkey instead of a formatted text --- diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 3b8a1f5e20..5013adb9a8 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -44,6 +44,9 @@ class ImagePage extends Article { function view() { global $wgOut, $wgShowEXIF, $wgRequest, $wgUser; + if ( $this->img->getRedirected() ) + return Article::view(); + $diff = $wgRequest->getVal( 'diff' ); $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); @@ -100,6 +103,15 @@ class ImagePage extends Article { "\n" ); } } + + public function getRedirectTarget() { + if ( $this->img->isLocal() ) + return parent::getRedirectTarget(); + + // Foreign image page + $from = $this->img->getRedirected(); + return $this->mRedirectTarget = Title::makeTitle( NS_IMAGE, $from ); + } /** * Create the TOC diff --git a/includes/Wiki.php b/includes/Wiki.php index 8f9368a017..2241c22559 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -252,10 +252,6 @@ class MediaWiki { switch( $title->getNamespace() ) { case NS_IMAGE: - $file = wfFindFile( $title ); - if( $file && $file->getRedirected() ) { - return new Article( $title ); - } return new ImagePage( $title ); case NS_CATEGORY: return new CategoryPage( $title ); diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index b7559e8633..5c847e1600 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -115,7 +115,7 @@ abstract class FileRepo { return false; } if( $img->exists() ) { - $img->redirectedFrom( $title->getText() ); + $img->redirectedFrom( $title->getDBkey() ); return $img; } }