From 9db190c7e736ec8d063187d4241b59feaf7dc2d1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 22 Jun 2011 11:28:20 +0200 Subject: update to MediaWiki 1.17.0 --- includes/HTMLFileCache.php | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'includes/HTMLFileCache.php') diff --git a/includes/HTMLFileCache.php b/includes/HTMLFileCache.php index 53af1e6e..26cb147d 100644 --- a/includes/HTMLFileCache.php +++ b/includes/HTMLFileCache.php @@ -7,8 +7,7 @@ /** * Handles talking to the file cache, putting stuff in and taking it back out. - * Mostly called from Article.php, also from DatabaseFunctions.php for the - * emergency abort/fallback to cache. + * Mostly called from Article.php for the emergency abort/fallback to cache. * * Global options that affect this module: * - $wgCachePages @@ -31,7 +30,7 @@ class HTMLFileCache { public function fileCacheName() { if( !$this->mFileCache ) { - global $wgCacheDirectory, $wgFileCacheDirectory, $wgRequest; + global $wgCacheDirectory, $wgFileCacheDirectory, $wgFileCacheDepth; if ( $wgFileCacheDirectory ) { $dir = $wgFileCacheDirectory; @@ -43,17 +42,21 @@ class HTMLFileCache { # Store raw pages (like CSS hits) elsewhere $subdir = ($this->mType === 'raw') ? 'raw/' : ''; + $key = $this->mTitle->getPrefixedDbkey(); - $hash = md5( $key ); + if ( $wgFileCacheDepth > 0 ) { + $hash = md5( $key ); + for ( $i = 1; $i <= $wgFileCacheDepth; $i++ ) { + $subdir .= substr( $hash, 0, $i ) . '/'; + } + } # Avoid extension confusion $key = str_replace( '.', '%2E', urlencode( $key ) ); - - $hash1 = substr( $hash, 0, 1 ); - $hash2 = substr( $hash, 0, 2 ); - $this->mFileCache = "{$wgFileCacheDirectory}/{$subdir}{$hash1}/{$hash2}/{$key}.html"; + $this->mFileCache = "{$dir}/{$subdir}{$key}.html"; - if( $this->useGzip() ) + if( $this->useGzip() ) { $this->mFileCache .= '.gz'; + } wfDebug( __METHOD__ . ": {$this->mFileCache}\n" ); } @@ -135,7 +138,7 @@ class HTMLFileCache { /* Working directory to/from output */ public function loadFromFileCache() { - global $wgOut, $wgMimeType, $wgOutputEncoding, $wgContLanguageCode; + global $wgOut, $wgMimeType, $wgOutputEncoding, $wgLanguageCode; wfDebug( __METHOD__ . "()\n"); $filename = $this->fileCacheName(); // Raw pages should handle cache control on their own, @@ -143,7 +146,7 @@ class HTMLFileCache { if( $this->mType !== 'raw' ) { $wgOut->sendCacheControl(); header( "Content-Type: $wgMimeType; charset={$wgOutputEncoding}" ); - header( "Content-Language: $wgContLanguageCode" ); + header( "Content-Language: $wgLanguageCode" ); } if( $this->useGzip() ) { @@ -210,11 +213,21 @@ class HTMLFileCache { public static function clearFileCache( $title ) { global $wgUseFileCache; - if( !$wgUseFileCache ) return false; + + if ( !$wgUseFileCache ) { + return false; + } + + wfSuppressWarnings(); + $fc = new self( $title, 'view' ); - @unlink( $fc->fileCacheName() ); + unlink( $fc->fileCacheName() ); + $fc = new self( $title, 'raw' ); - @unlink( $fc->fileCacheName() ); + unlink( $fc->fileCacheName() ); + + wfRestoreWarnings(); + return true; } } -- cgit v1.2.3-54-g00ecf