Clean up ipb_deleted query slightly
[lhc/web/wiklou.git] / includes / HTMLFileCache.php
index 833d718..68cafa2 100644 (file)
@@ -128,15 +128,14 @@ class HTMLFileCache {
        public function loadFromFileCache() {
                global $wgOut, $wgMimeType, $wgOutputEncoding, $wgContLanguageCode;
                wfDebug(" loadFromFileCache()\n");
-
                $filename = $this->fileCacheName();
                // Raw pages should handle cache control on their own,
                // even when using file cache. This reduces hits from clients.
-               if( $this->mType !== 'raw' )
+               if( $this->mType !== 'raw' ) {
                        $wgOut->sendCacheControl();
-
-               header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
-               header( "Content-language: $wgContLanguageCode" );
+                       header( "Content-Type: $wgMimeType; charset={$wgOutputEncoding}" );
+                       header( "Content-Language: $wgContLanguageCode" );
+               }
 
                if( $this->useGzip() ) {
                        if( wfClientAcceptsGzip() ) {
@@ -148,6 +147,7 @@ class HTMLFileCache {
                        }
                }
                readfile( $filename );
+               $wgOut->disable(); // tell $wgOut that output is taken care of
        }
 
        protected function checkCacheDirs() {
@@ -159,13 +159,12 @@ class HTMLFileCache {
                wfMkdirParents( $mydir2 );
        }
 
-       public function saveToFileCache( $origtext ) {
+       public function saveToFileCache( $text ) {
                global $wgUseFileCache;
-               if( !$wgUseFileCache ) {
-                       return $origtext; // return to output
+               if( !$wgUseFileCache || strlen( $text ) < 512 ) {
+                       // Disabled or empty/broken output (OOM and PHP errors)
+                       return $text;
                }
-               $text = $origtext;
-               if( strcmp($text,'') == 0 ) return '';
 
                wfDebug(" saveToFileCache()\n", false);
 
@@ -203,7 +202,7 @@ class HTMLFileCache {
        public static function clearFileCache( $title ) {
                global $wgUseFileCache;
                if( !$wgUseFileCache ) return false;
-               $fc = new self( $title, '' );
+               $fc = new self( $title, 'view' );
                @unlink( $fc->fileCacheName() );
                $fc = new self( $title, 'raw' );
                @unlink( $fc->fileCacheName() );