From: Bryan Tong Minh Date: Sat, 10 May 2008 14:19:25 +0000 (+0000) Subject: Don't call wfFindFile twice when it's not necessary. X-Git-Tag: 1.31.0-rc.0~47733 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=bbfcb113c391269428f0091cc5e12175266b66b3;p=lhc%2Fweb%2Fwiklou.git Don't call wfFindFile twice when it's not necessary. --- diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 9b48d1b4ec..7579399772 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -134,6 +134,10 @@ class ImagePage extends Article { public function isLocal() { return $this->img->isLocal(); } + + public function getFile() { + return $this->img; + } /** * Create the TOC diff --git a/includes/Wiki.php b/includes/Wiki.php index 3c178aaeab..9dc570ff5a 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -278,12 +278,13 @@ class MediaWiki { // Namespace might change when using redirects // Check for redirects ... + $file = $title->getNamespace() == NS_IMAGE ? $article->getFile() : null; if( ( $action == 'view' || $action == 'render' ) // ... for actions that show content && !$request->getVal( 'oldid' ) && // ... and are not old revisions $request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to // ... and the article is not an image page with associated file - !( $title->getNamespace() == NS_IMAGE && wfFindFile( $title->getText(), false, - FileRepo::FIND_IGNORE_REDIRECT ) ) ) { // ... unless it is really an image redirect + !( is_object( $file ) && $file->exists() && + !$file->getRedirected() ) ) { // ... unless it is really an image redirect $dbr = wfGetDB( DB_SLAVE ); $article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) ); @@ -303,8 +304,8 @@ class MediaWiki { $rarticle = self::articleFromTitle( $target ); $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) ); if ( $rarticle->getTitle()->exists() || - ( $title->getNamespace() == NS_IMAGE && - !$article->isLocal() ) ) { + ( is_object( $file ) && + !$file->isLocal() ) ) { $rarticle->setRedirectedFrom( $title ); $article = $rarticle; $title = $target;