diff options
Diffstat (limited to 'includes/cache/FileCacheBase.php')
-rw-r--r-- | includes/cache/FileCacheBase.php | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php index 37401655..c0c5609c 100644 --- a/includes/cache/FileCacheBase.php +++ b/includes/cache/FileCacheBase.php @@ -1,9 +1,31 @@ <?php /** - * Contain the FileCacheBase class + * Data storage in the file system. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Cache */ + +/** + * Base class for data storage in the file system. + * + * @ingroup Cache + */ abstract class FileCacheBase { protected $mKey; protected $mType = 'object'; @@ -74,7 +96,7 @@ abstract class FileCacheBase { /** * Get the last-modified timestamp of the cache file - * @return string|false TS_MW timestamp + * @return string|bool TS_MW timestamp */ public function cacheTimestamp() { $timestamp = filemtime( $this->cachePath() ); @@ -116,9 +138,12 @@ abstract class FileCacheBase { * @return string */ public function fetchText() { - // gzopen can transparently read from gziped or plain text - $fh = gzopen( $this->cachePath(), 'rb' ); - return stream_get_contents( $fh ); + if( $this->useGzip() ) { + $fh = gzopen( $this->cachePath(), 'rb' ); + return stream_get_contents( $fh ); + } else { + return file_get_contents( $this->cachePath() ); + } } /** |