r34583 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34582‎ | r34583 | r34584 >
Date:14:19, 10 May 2008
Author:btongminh
Status:old
Tags:
Comment:
Don't call wfFindFile twice when it's not necessary.
Modified paths:
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ImagePage.php
@@ -134,6 +134,10 @@
135135 public function isLocal() {
136136 return $this->img->isLocal();
137137 }
 138+
 139+ public function getFile() {
 140+ return $this->img;
 141+ }
138142
139143 /**
140144 * Create the TOC
Index: trunk/phase3/includes/Wiki.php
@@ -278,12 +278,13 @@
279279
280280 // Namespace might change when using redirects
281281 // Check for redirects ...
 282+ $file = $title->getNamespace() == NS_IMAGE ? $article->getFile() : null;
282283 if( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
283284 && !$request->getVal( 'oldid' ) && // ... and are not old revisions
284285 $request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to
285286 // ... and the article is not an image page with associated file
286 - !( $title->getNamespace() == NS_IMAGE && wfFindFile( $title->getText(), false,
287 - FileRepo::FIND_IGNORE_REDIRECT ) ) ) { // ... unless it is really an image redirect
 287+ !( is_object( $file ) && $file->exists() &&
 288+ !$file->getRedirected() ) ) { // ... unless it is really an image redirect
288289
289290 $dbr = wfGetDB( DB_SLAVE );
290291 $article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) );
@@ -303,8 +304,8 @@
304305 $rarticle = self::articleFromTitle( $target );
305306 $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) );
306307 if ( $rarticle->getTitle()->exists() ||
307 - ( $title->getNamespace() == NS_IMAGE &&
308 - !$article->isLocal() ) ) {
 308+ ( is_object( $file ) &&
 309+ !$file->isLocal() ) ) {
309310 $rarticle->setRedirectedFrom( $title );
310311 $article = $rarticle;
311312 $title = $target;

Status & tagging log