Move some of this caching logic out of the file and into the repo where it belongs.
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 29 Sep 2008 08:23:16 +0000 (08:23 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 29 Sep 2008 08:23:16 +0000 (08:23 +0000)
includes/filerepo/ForeignAPIFile.php
includes/filerepo/ForeignAPIRepo.php

index 336c928..22f2316 100644 (file)
@@ -31,17 +31,10 @@ class ForeignAPIFile extends File {
        }
 
        function transform( $params, $flags = 0 ) {
-               if ( $this->repo->canCacheThumbs() ) {
-                       $thumbUrl = $this->repo->getThumbUrlFromCache(
-                               $this->getName(),
-                               isset( $params['width'] ) ? $params['width'] : -1,
-                               isset( $params['height'] ) ? $params['height'] : -1 );
-               } else {
-                       $thumbUrl = $this->repo->getThumbUrl(
+               $thumbUrl = $this->repo->getThumbUrlFromCache(
                                $this->getName(),
                                isset( $params['width'] ) ? $params['width'] : -1,
                                isset( $params['height'] ) ? $params['height'] : -1 );
-               }
                if( $thumbUrl ) {
                        return $this->handler->getTransform( $this, 'bogus', $thumbUrl, $params );;
                }
index 2ba72fb..e174df9 100644 (file)
@@ -113,6 +113,10 @@ class ForeignAPIRepo extends FileRepo {
        function getThumbUrlFromCache( $name, $width, $height ) {
                global $wgMemc, $wgUploadPath, $wgServer, $wgUploadDirectory;
                
+               if ( !$this->canCacheThumbs() ) {
+                       return $this->getThumbUrl();
+               }
+               
                $key = wfMemcKey( 'ForeignAPIRepo', 'ThumbUrl', $name );
                if ( $thumbUrl = $wgMemc->get($key) ) {
                        wfDebug("Got thumb from local cache. $thumbUrl \n");