Avoid undefined variable error on null edits
[lhc/web/wiklou.git] / includes / CacheManager.php
index 7a68114..9f8abc1 100644 (file)
@@ -1,18 +1,28 @@
 <?php
+/**
+ * Contain the CacheManager class
+ * @package MediaWiki
+ * @subpackage Cache
+ */
 
-# 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.
-
-# Global options that affect this module:
-# $wgCachePages
-# $wgCacheEpoch
-# $wgUseFileCache
-# $wgFileCacheDirectory
-# $wgUseGzip
-
+/**
+ * We need the title class
+ */
 require_once( 'Title.php' );
 
+/**
+ * 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.
+ * 
+ * Global options that affect this module:
+ * $wgCachePages
+ * $wgCacheEpoch
+ * $wgUseFileCache
+ * $wgFileCacheDirectory
+ * $wgUseGzip
+ * @package MediaWiki 
+ */
 class CacheManager {
        var $mTitle, $mFileCache;
        
@@ -22,11 +32,10 @@ class CacheManager {
        }
        
        function fileCacheName() {
-               global $wgFileCacheDirectory, $wgLang;
+               global $wgFileCacheDirectory;
                if( !$this->mFileCache ) {
-                       $hash = md5( $key = $this->mTitle->getDbkey() );
-                       if( $this->mTitle->getNamespace() )
-                               $key = $wgLang->getNsText( $this->mTitle->getNamespace() ) . ":" . $key;
+                       $key = $this->mTitle->getPrefixedDbkey();
+                       $hash = md5( $key );
                        $key = str_replace( '.', '%2E', urlencode( $key ) );
                        
                        $hash1 = substr( $hash, 0, 1 );
@@ -46,7 +55,7 @@ class CacheManager {
        }
        
        function fileCacheTime() {
-               return wfUnix2Timestamp( filemtime( $this->fileCacheName() ) );
+               return wfTimestamp( TS_MW, filemtime( $this->fileCacheName() ) );
        }
        
        function isFileCacheGood( $timestamp ) {
@@ -83,11 +92,14 @@ class CacheManager {
        
        /* Working directory to/from output */
        function loadFromFileCache() {
-               global $wgOut;
+               global $wgOut, $wgMimeType, $wgOutputEncoding, $wgContLanguageCode;
                wfDebug(" loadFromFileCache()\n");
                
                $filename=$this->fileCacheName();
                $wgOut->sendCacheControl();
+
+               header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
+               header( "Content-language: $wgContLanguageCode" );
                
                if( $this->useGzip() ) {
                        if( wfClientAcceptsGzip() ) {