From d9ee85ad29a3b7fcae07307a0421c351a7f6e5af Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 23 Sep 2008 00:07:24 +0000 Subject: [PATCH] Redo r41164 with less breakage. --- includes/filerepo/ForeignAPIFile.php | 4 ++-- includes/filerepo/ForeignAPIRepo.php | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index 42bd7e10b8..336c928004 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -31,7 +31,7 @@ class ForeignAPIFile extends File { } function transform( $params, $flags = 0 ) { - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) { + if ( $this->repo->canCacheThumbs() ) { $thumbUrl = $this->repo->getThumbUrlFromCache( $this->getName(), isset( $params['width'] ) ? $params['width'] : -1, @@ -110,7 +110,7 @@ class ForeignAPIFile extends File { */ function getThumbPath( $suffix = '' ) { $ret = null; - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) { + if ( $this->repo->canCacheThumbs() ) { global $wgUploadDirectory; $path = $wgUploadDirectory . '/' . $this->repo->apiThumbCacheDir . '/' . $this->repo->name . '/'; if ( $suffix ) { diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index bd53686d12..2ba72fb11c 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -112,7 +112,6 @@ class ForeignAPIRepo extends FileRepo { function getThumbUrlFromCache( $name, $width, $height ) { global $wgMemc, $wgUploadPath, $wgServer, $wgUploadDirectory; -; $key = wfMemcKey( 'ForeignAPIRepo', 'ThumbUrl', $name ); if ( $thumbUrl = $wgMemc->get($key) ) { @@ -135,4 +134,12 @@ class ForeignAPIRepo extends FileRepo { return $localUrl; } } + + /** + * Are we locally caching the thumbnails? + * @return bool + */ + public function canCacheThumbs() { + return ( $this->apiThumbCacheExpiry > 0 && $this->apiThumbCacheDir ); + } } -- 2.20.1