From: Chad Horohoe Date: Mon, 29 Sep 2008 08:23:16 +0000 (+0000) Subject: Move some of this caching logic out of the file and into the repo where it belongs. X-Git-Tag: 1.31.0-rc.0~45023 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=9d0bb535fe3c13278b47957187f45f29718da06d;p=lhc%2Fweb%2Fwiklou.git Move some of this caching logic out of the file and into the repo where it belongs. --- diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index 336c928004..22f23160c9 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -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 );; } diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index 2ba72fb11c..e174df97f6 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -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");