Add new config variable $wgFileCacheDepth to set the depth of the subdirectory hierar...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Sun, 5 Dec 2010 23:07:48 +0000 (23:07 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Sun, 5 Dec 2010 23:07:48 +0000 (23:07 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/HTMLFileCache.php

index 7f7473d..3fa46c5 100644 (file)
@@ -89,6 +89,8 @@ LocalSettings.php. The specific bugs are listed below in the general notes.
 * Sysops now have the "suppressredirect" right by default
 * (bug 22463) $wgFooterIcons added to allow configuration of the icons shown in
   the footers of skins.
+* $wgFileCacheDepth can be used to set the depth of the subdirectory hierarchy
+  used for the file cache. Default value is 2, which matches former behavior 
 
 === New features in 1.17 ===
 * (bug 10183) Users can now add personal styles and scripts to all skins via
index 47db322..33a6101 100644 (file)
@@ -1601,6 +1601,14 @@ $wgUseFileCache = false;
  */
 $wgFileCacheDirectory = false;
 
+/**
+ * Depth of the subdirectory hierarchy to be created under
+ * $wgFileCacheDirectory.  The subdirectories will be named based on
+ * the MD5 hash of the title.  A value of 0 means all cache files will
+ * be put directly into the main file cache directory.
+ */
+$wgFileCacheDepth = 2;
+
 /**
  * Keep parsed pages in a cache (objectcache table or memcached)
  * to speed up output of the same page viewed by another user with the
index 80744f7..e167150 100644 (file)
@@ -30,7 +30,7 @@ class HTMLFileCache {
 
        public function fileCacheName() {
                if( !$this->mFileCache ) {
-                       global $wgCacheDirectory, $wgFileCacheDirectory;
+                       global $wgCacheDirectory, $wgFileCacheDirectory, $wgFileCacheDepth;
 
                        if ( $wgFileCacheDirectory ) {
                                $dir = $wgFileCacheDirectory;
@@ -42,14 +42,17 @@ 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 = "{$dir}/{$subdir}{$hash1}/{$hash2}/{$key}.html";
+                       $this->mFileCache = "{$dir}/{$subdir}{$key}.html";
 
                        if( $this->useGzip() ) {
                                $this->mFileCache .= '.gz';