X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FHTMLFileCache.php;h=53af1e6e12a7b1d57e9a301688d662ae7096c3f6;hb=260cc188fa13f4ce81f47f585e64121739b2cad3;hp=5745de43341d211f50e211ca85c01bef7598fbcc;hpb=4c881d994731f61908bc4b5b4db119bb2ce40384;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HTMLFileCache.php b/includes/HTMLFileCache.php index 5745de4334..53af1e6e12 100644 --- a/includes/HTMLFileCache.php +++ b/includes/HTMLFileCache.php @@ -14,6 +14,7 @@ * - $wgCachePages * - $wgCacheEpoch * - $wgUseFileCache + * - $wgCacheDirectory * - $wgFileCacheDirectory * - $wgUseGzip * @@ -30,7 +31,16 @@ class HTMLFileCache { public function fileCacheName() { if( !$this->mFileCache ) { - global $wgFileCacheDirectory, $wgRequest; + global $wgCacheDirectory, $wgFileCacheDirectory, $wgRequest; + + if ( $wgFileCacheDirectory ) { + $dir = $wgFileCacheDirectory; + } elseif ( $wgCacheDirectory ) { + $dir = "$wgCacheDirectory/html"; + } else { + throw new MWException( 'Please set $wgCacheDirectory in LocalSettings.php if you wish to use the HTML file cache' ); + } + # Store raw pages (like CSS hits) elsewhere $subdir = ($this->mType === 'raw') ? 'raw/' : ''; $key = $this->mTitle->getPrefixedDbkey(); @@ -45,7 +55,7 @@ class HTMLFileCache { if( $this->useGzip() ) $this->mFileCache .= '.gz'; - wfDebug( " fileCacheName() - {$this->mFileCache}\n" ); + wfDebug( __METHOD__ . ": {$this->mFileCache}\n" ); } return $this->mFileCache; } @@ -96,12 +106,11 @@ class HTMLFileCache { global $wgCacheEpoch; if( !$this->isFileCached() ) return false; - if( !$timestamp ) return true; // should be invalidated on change $cachetime = $this->fileCacheTime(); $good = $timestamp <= $cachetime && $wgCacheEpoch <= $cachetime; - wfDebug(" isFileCacheGood() - cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good\n"); + wfDebug( __METHOD__ . ": cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good\n"); return $good; } @@ -127,8 +136,7 @@ class HTMLFileCache { /* Working directory to/from output */ public function loadFromFileCache() { global $wgOut, $wgMimeType, $wgOutputEncoding, $wgContLanguageCode; - wfDebug(" loadFromFileCache()\n"); - + wfDebug( __METHOD__ . "()\n"); $filename = $this->fileCacheName(); // Raw pages should handle cache control on their own, // even when using file cache. This reduces hits from clients. @@ -148,6 +156,7 @@ class HTMLFileCache { } } readfile( $filename ); + $wgOut->disable(); // tell $wgOut that output is taken care of } protected function checkCacheDirs() { @@ -166,7 +175,7 @@ class HTMLFileCache { return $text; } - wfDebug(" saveToFileCache()\n", false); + wfDebug( __METHOD__ . "()\n", false); $this->checkCacheDirs();