From: Antoine Musso Date: Tue, 7 Feb 2012 20:47:45 +0000 (+0000) Subject: simplify FileCacheBase::fetchText X-Git-Tag: 1.31.0-rc.0~24887 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=8cbd865d2cec0194ef60338332ce0d1271f4487c;p=lhc%2Fweb%2Fwiklou.git simplify FileCacheBase::fetchText Implements a proposal by Tim on r98405 CR --- diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php index 00fe995793..29cc8a13fc 100644 --- a/includes/cache/FileCacheBase.php +++ b/includes/cache/FileCacheBase.php @@ -116,12 +116,9 @@ abstract class FileCacheBase { * @return string */ public function fetchText() { - if ( $this->useGzip() ) { - /* Why is there no gzfile_get_contents() or gzdecode()? */ - return implode( '', gzfile( $this->cachePath() ) ); - } else { - return file_get_contents( $this->cachePath() ); - } + // gzopen can transparently read from gziped or plain text + $fh = gzopen( $this->cachePath(), 'r' ); + return stream_get_contents( $fh ); } /** @@ -141,6 +138,7 @@ abstract class FileCacheBase { $this->checkCacheDirs(); // build parent dir if ( !file_put_contents( $this->cachePath(), $text, LOCK_EX ) ) { + wfDebug( __METHOD__ . "() failed saving ". $this->cachePath() . "\n"); $this->mCached = null; return false; }