public function fileCacheName() {
if( !$this->mFileCache ) {
- global $wgCacheDirectory, $wgFileCacheDirectory;
+ global $wgCacheDirectory, $wgFileCacheDirectory, $wgFileCacheDepth;
- if ( !$wgFileCacheDirectory && !$wgCacheDirectory ) {
+ 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();
- $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() ) {
$this->mFileCache .= '.gz';