Merge "Making missing old files not try to render a thumbnail"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 28 Aug 2014 07:43:26 +0000 (07:43 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 28 Aug 2014 07:43:26 +0000 (07:43 +0000)
includes/filerepo/file/File.php
includes/filerepo/file/OldLocalFile.php
includes/page/ImagePage.php

index 4fab33b..ba2d4ac 100644 (file)
@@ -714,7 +714,7 @@ abstract class File {
         */
        function canRender() {
                if ( !isset( $this->canRender ) ) {
-                       $this->canRender = $this->getHandler() && $this->handler->canRender( $this );
+                       $this->canRender = $this->getHandler() && $this->handler->canRender( $this ) && $this->exists();
                }
 
                return $this->canRender;
index 0adcc73..710058f 100644 (file)
@@ -404,4 +404,18 @@ class OldLocalFile extends LocalFile {
 
                return true;
        }
+
+       /**
+        * If archive name is an empty string, then file does not "exist"
+        *
+        * This is the case for a couple files on Wikimedia servers where
+        * the old version is "lost".
+        */
+       public function exists() {
+               $archiveName = $this->getArchiveName();
+               if ( $archiveName === '' || !is_string( $archiveName ) ) {
+                       return false;
+               }
+               return parent::exists();
+       }
 }
index 380252f..5811f63 100644 (file)
@@ -1329,6 +1329,9 @@ class ImageHistoryList extends ContextSource {
                                $url = $lang->userTimeAndDate( $timestamp, $user );
                        }
                        $row .= '<span class="history-deleted">' . $url . '</span>';
+               } elseif ( !$file->exists() ) {
+                       $row .= '<span class="mw-file-missing">'
+                               . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
                } else {
                        $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
                        $row .= Xml::element(