[FileRepo] Avoid performance degeration due to thumbnail requests with a read-only...
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 21 Apr 2012 18:47:14 +0000 (11:47 -0700)
committerAaron <aschulz@wikimedia.org>
Tue, 24 Apr 2012 18:15:49 +0000 (11:15 -0700)
Change-Id: I8663e64a0f16dac6d763a3f770b48c9be36680b8

includes/filerepo/file/File.php

index ae11e67..461c255 100644 (file)
@@ -842,6 +842,13 @@ abstract class File {
                                }
                        }
 
+                       // If the backend is ready-only, don't keep generating thumbnails
+                       // only to return transformation errors, just return the error now.
+                       if ( $this->repo->getReadOnlyReason() !== false ) {
+                               $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
+                               break;
+                       }
+
                        // Create a temp FS file with the same extension and the thumbnail
                        $thumbExt = FileBackend::extensionFromPath( $thumbPath );
                        $tmpFile = TempFSFile::factory( 'transform_', $thumbExt );