Merge changes from 1.4:
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 9 Mar 2005 02:02:04 +0000 (02:02 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 9 Mar 2005 02:02:04 +0000 (02:02 +0000)
* Squid purged defered to outside the db transaction
* Partial redirect goodies
* Compression threadhold on memcached
* setproctitle
* Some other tweaks

includes/Article.php
includes/Setup.php
index.php

index 62f3129..a216fc9 100644 (file)
@@ -393,11 +393,11 @@ class Article {
         * Get the database which should be used for reads
         */
        function &getDB() {
-               if ( $this->mForUpdate ) {
+               #if ( $this->mForUpdate ) {
                        return wfGetDB( DB_MASTER );
-               } else {
-                       return wfGetDB( DB_SLAVE );
-               }
+               #} else {
+               #       return wfGetDB( DB_SLAVE );
+               #}
        }
 
        /**
@@ -575,6 +575,7 @@ class Article {
                $oldid = $this->getOldID();
                $diff = $wgRequest->getVal( 'diff' );
                $rcid = $wgRequest->getVal( 'rcid' );
+               $rdfrom = $wgRequest->getVal( 'rdfrom' );
 
                $wgOut->setArticleFlag( true );
                $wgOut->setRobotpolicy( 'index,follow' );
@@ -644,6 +645,11 @@ class Article {
 
                                # Can't cache redirects
                                $pcache = false;
+                       } elseif ( !empty( $rdfrom ) ) {
+                               $sk = $wgUser->getSkin();
+                               $redir = $sk->makeExternalLink( $rdfrom, $rdfrom );
+                               $s = wfMsg( 'redirectedfrom', $redir );
+                               $wgOut->setSubtitle( $s );
                        }
 
                        # wrap user css and user js in pre and don't parse
@@ -907,7 +913,7 @@ class Article {
        function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) {
                global $wgOut, $wgUser;
                global $wgDBtransactions, $wgMwRedir;
-               global $wgUseSquid, $wgInternalServer;
+               global $wgUseSquid, $wgInternalServer, $wgPostCommitUpdateList;
 
                $fname = 'Article::updateArticle';
                $good = true;
@@ -1037,7 +1043,7 @@ class Article {
                if ( $wgUseSquid ) {
                        $urls = array_merge( $urls, $this->mTitle->getSquidURLs() );
                        $u = new SquidUpdate( $urls );
-                       $u->doUpdate();
+                       array_push( $wgPostCommitUpdateList, $u );
                }
 
                $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $me2, $now, $summary, $lastRevision );
@@ -1556,7 +1562,7 @@ class Article {
         */
        function doDeleteArticle( $reason ) {
                global $wgUser;
-               global  $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
+               global  $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer, $wgPostCommitUpdateList;
 
                $fname = 'Article::doDeleteArticle';
                wfDebug( $fname."\n" );
@@ -1586,7 +1592,7 @@ class Article {
                        }
 
                        $u = new SquidUpdate( $urls );
-                       array_push( $wgDeferredUpdateList, $u );
+                       array_push( $wgPostCommitUpdateList, $u );
 
                }
 
@@ -2044,7 +2050,7 @@ class Article {
         */
 
        function onArticleCreate($title_obj) {
-               global $wgUseSquid, $wgDeferredUpdateList;
+               global $wgUseSquid, $wgPostCommitUpdateList;
 
                $titles = $title_obj->getBrokenLinksTo();
 
@@ -2055,7 +2061,7 @@ class Article {
                                $urls[] = $linkTitle->getInternalURL();
                        }
                        $u = new SquidUpdate( $urls );
-                       array_push( $wgDeferredUpdateList, $u );
+                       array_push( $wgPostCommitUpdateList, $u );
                }
 
                # Clear persistent link cache
index 2d48329..f62fda0 100644 (file)
@@ -21,15 +21,28 @@ global $wgProfiling, $wgProfileSampleRate, $wgIP, $wgUseSquid, $IP;
 if( !isset( $wgProfiling ) )
        $wgProfiling = false;
 
-if ( $wgProfiling and (0 == rand() % $wgProfileSampleRate ) ) {        
-       require_once( 'Profiling.php' );
+if ( $wgProfiling and (0 == rand() % $wgProfileSampleRate ) ) {
+        require_once( 'Profiling.php' );
 } else {
-       function wfProfileIn( $fn = '' ) {}
-       function wfProfileOut( $fn = '' ) {}
-       function wfGetProfilingOutput( $s, $e ) {}
-       function wfProfileClose() {}
+        function wfProfileIn( $fn = '' ) {
+                global $hackwhere, $wgDBname;
+                $hackwhere[] = $fn;
+                if (function_exists("setproctitle"))
+                        setproctitle($fn . " [$wgDBname]");
+        }
+        function wfProfileOut( $fn = '' ) {
+                global $hackwhere, $wgDBname;
+                if (count($hackwhere))
+                        array_pop($hackwhere);
+                if (function_exists("setproctitle") && count($hackwhere))
+                        setproctitle($hackwhere[count($hackwhere)-1] . " [$wgDBname]");
+        }
+        function wfGetProfilingOutput( $s, $e ) {}
+        function wfProfileClose() {}
 }
 
+
+
 /* collect the originating ips */
 if( $wgUseSquid && isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
        # If the web server is behind a reverse proxy, we need to find
@@ -134,7 +147,7 @@ if( $wgUseMemCached ) {
                }
        }
 
-       $wgMemc = new MemCachedClientforWiki( array('persistant' => true) );
+       $wgMemc = new MemCachedClientforWiki( array('persistant' => true, 'compress_threshold' => 1500 ) );
        $wgMemc->set_servers( $wgMemCachedServers );
        $wgMemc->set_debug( $wgMemCachedDebug );
 
@@ -351,6 +364,8 @@ wfProfileOut( $fname.'-BlockCache' );
 wfProfileIn( $fname.'-misc2' );
 
 $wgDeferredUpdateList = array();
+$wgPostCommitUpdateList = array();
+
 $wgLinkCache = new LinkCache();
 $wgMagicWords = array();
 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
index cbb5137..ec62796 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,4 +1,5 @@
 <?php
+
 #apd_set_pprof_trace();
 # Main wiki script; see design.doc
 #
@@ -209,6 +210,11 @@ $wgLoadBalancer->saveMasterPos();
 $wgLoadBalancer->commitAll();
 
 $wgOut->output();
+
+foreach ( $wgPostCommitUpdateList as $up ) {
+       $up->doUpdate();
+}
+
 wfProfileOut( 'main-cleanup' );
 
 logProfilingData();