From: Chad Horohoe Date: Thu, 3 Jul 2008 19:02:47 +0000 (+0000) Subject: Cache thumbs from remote sources too. X-Git-Tag: 1.31.0-rc.0~46772 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=d6f44cf5677da86268311b63eef2515cbbc2c194;p=lhc%2Fweb%2Fwiklou.git Cache thumbs from remote sources too. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7186bf1f24..047c8a6d5a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -179,8 +179,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Added blank special page Special:BlankPage for benchmarking, etc. * (bug 13862) Specialpages now has a horizontal TOC if there's three or more groups. -* Foreign repo file descriptions via fetchDescription are now cached in the - transcache. +* Foreign repo file descriptions and thumbnails are now cached. === Bug fixes in 1.13 === diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index aaf922048e..d0add602b6 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -31,13 +31,26 @@ class ForeignAPIFile extends File { } function transform( $params, $flags = 0 ) { + global $wgMemc; $thumbUrl = $this->repo->getThumbUrl( $this->getName(), isset( $params['width'] ) ? $params['width'] : -1, isset( $params['height'] ) ? $params['height'] : -1 ); if( $thumbUrl ) { + if ( $this->repo->useLocalCache ) { + wfDebug("Attempting to get the thumb from the cache..."); + $key = md5($thumbUrl); + $obj = $wgMemc->get($key); + if ($obj) { + wfDebug("success!\n"); + return $obj; + } + wfDebug("miss\n"); + } + $res = $this->handler->getTransform( $this, 'bogus', $thumbUrl, $params );; + if ( $res && $this->repo->useLocalCache ) $wgMemc->set( $key, $res, $this->repo->localCacheExpiry ); wfDebug( __METHOD__ . " got remote thumb $thumbUrl\n" ); - return $this->handler->getTransform( $this, 'bogus', $thumbUrl, $params );; + return $res; } return false; }