Simplified some code and broke lines in thumb.php
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 29 Aug 2013 20:31:12 +0000 (13:31 -0700)
committerBryanDavis <bdavis@wikimedia.org>
Fri, 20 Sep 2013 18:10:31 +0000 (18:10 +0000)
Change-Id: I99fc63ab473a3f2fe33e0227e5e283e0c195f01b

thumb.php

index 2b68927..2cda344 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -171,20 +171,17 @@ function wfStreamThumb( array $params ) {
                $redirectedLocation = false;
                if ( !$isTemp ) {
                        // Check for file redirect
-                       if ( $isOld ) {
-                               // Since redirects are associated with pages, not versions of files,
-                               // we look for the most current version to see if its a redirect.
-                               $possibleRedirFile = RepoGroup::singleton()->getLocalRepo()->findFile( $img->getName() );
-                       } else {
-                               $possibleRedirFile = RepoGroup::singleton()->getLocalRepo()->findFile( $fileName );
-                       }
-                       if ( $possibleRedirFile && !is_null( $possibleRedirFile->getRedirected() ) ) {
-                               $redirTarget = $possibleRedirFile->getName();
+                       // Since redirects are associated with pages, not versions of files,
+                       // we look for the most current version to see if its a redirect.
+                       $possRedirFile = RepoGroup::singleton()->getLocalRepo()->findFile( $img->getName() );
+                       if ( $possRedirFile && !is_null( $possRedirFile->getRedirected() ) ) {
+                               $redirTarget = $possRedirFile->getName();
                                $targetFile = wfLocalFile( Title::makeTitleSafe( NS_FILE, $redirTarget ) );
                                if ( $targetFile->exists() ) {
                                        $newThumbName = $targetFile->thumbName( $params );
                                        if ( $isOld ) {
-                                               $newThumbUrl = $targetFile->getArchiveThumbUrl( $bits[0] . '!' . $targetFile->getName(), $newThumbName );
+                                               $newThumbUrl = $targetFile->getArchiveThumbUrl(
+                                                       $bits[0] . '!' . $targetFile->getName(), $newThumbName );
                                        } else {
                                                $newThumbUrl = $targetFile->getThumbUrl( $newThumbName );
                                        }