cache tweaks
[lhc/web/wiklou.git] / includes / Article.php
index 2afda77..17226b3 100644 (file)
@@ -384,7 +384,7 @@ class Article {
                global $oldid, $redirect, $section;
                global $wgLang;
 
-               if($wpSection) { $section=$wpSection; }
+               if(isset($wpSection)) { $section=$wpSection; }
 
                $sk = $wgUser->getSkin();
                $isConflict = false;
@@ -611,7 +611,7 @@ name=\"wpSummary\" maxlength=200 size=60><br>
                $now = wfTimestampNow();
                $won = wfInvertTimestamp( $now );
                wfSeedRandom();
-               $rand = mt_rand() / mt_getrandmax();
+               $rand = number_format( mt_rand() / mt_getrandmax(), 12, ".", "" );
                $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
                  "cur_comment,cur_user,cur_timestamp,cur_minor_edit,cur_counter," .
                  "cur_restrictions,cur_user_text,cur_is_redirect," .
@@ -751,10 +751,18 @@ name=\"wpSummary\" maxlength=200 size=60><br>
 
        function showArticle( $text, $subtitle )
        {
-               global $wgOut, $wgTitle, $wgUser, $wgLinkCache;
+               global $wgOut, $wgTitle, $wgUser, $wgLinkCache, $wgUseBetterLinksUpdate;
 
                $wgLinkCache = new LinkCache();
-               $wgOut->addWikiText( $text ); # Just to update links
+
+               # Get old version of link table to allow incremental link updates
+               if ( $wgUseBetterLinksUpdate ) {
+                       $wgLinkCache->preFill( $wgTitle );
+                       $wgLinkCache->clear();
+               }
+
+               # Now update the link cache by parsing the text
+               $wgOut->addWikiText( $text );
 
                $this->editUpdates( $text );
                if( preg_match( "/^#redirect/i", $text ) )
@@ -1633,17 +1641,18 @@ name=\"wpSummary\" maxlength=200 size=60><br>
                global $wgUser, $wgCacheEpoch;
                if(!file_exists( $fn = $this->fileCacheName() ) ) return false;
                $cachetime = wfUnix2Timestamp( filemtime( $fn ) );
-               $good = ( $this->mTouched <= $cachetime ) &&
-                       ($wgCacheEpoch <= $cachetime );
+               $good = (( $this->mTouched <= $cachetime ) &&
+                       ($wgCacheEpoch <= $cachetime ));
         wfDebug(" isFileCacheGood() - cachetime $cachetime, touched {$this->mTouched} epoch {$wgCacheEpoch}, good $good\n");
                return $good;
        }
 
        function loadFromFileCache() {
-               global $wgUseGzip;
+               global $wgUseGzip, $wgOut;
                wfDebug(" loadFromFileCache()\n");
                $filename=$this->fileCacheName();
                $filenamegz = "{$filename}.gz";
+               $wgOut->sendCacheControl();
                if( $wgUseGzip
                        && wfClientAcceptsGzip()
                        && file_exists( $filenamegz)
@@ -1659,12 +1668,13 @@ name=\"wpSummary\" maxlength=200 size=60><br>
        function saveToFileCache( $text ) {
                global $wgUseGzip, $wgCompressByDefault;
                
-        wfDebug(" saveToFileCache()\n");
+        wfDebug(" saveToFileCache()\n", false);
                $filename=$this->fileCacheName();
                 $mydir2=substr($filename,0,strrpos($filename,"/")); # subdirectory level 2
                $mydir1=substr($mydir2,0,strrpos($mydir2,"/")); # subdirectory level 1
-               if(!file_exists($mydir1)) { mkdir($mydir1,0777); } # create if necessary
-               if(!file_exists($mydir2)) { mkdir($mydir2,0777); }                      
+               if(!file_exists($mydir1)) { mkdir($mydir1,0775); } # create if necessary
+               if(!file_exists($mydir2)) { mkdir($mydir2,0775); }
+               
                $f = fopen( $filename, "w" );
                if($f) {
                        $now = wfTimestampNow();
@@ -1698,6 +1708,7 @@ name=\"wpSummary\" maxlength=200 size=60><br>
                                if(wfClientAcceptsGzip()) {
                                        header( "Content-Encoding: gzip" );
                                        header( "Vary: Accept-Encoding" );
+                                       wfDebug("  sending NEW gzip now...\n" );
                                        return $gzout;
                                }
                        }