From: Brion Vibber Date: Wed, 9 Mar 2005 02:02:04 +0000 (+0000) Subject: Merge changes from 1.4: X-Git-Tag: 1.5.0alpha1~662 X-Git-Url: http://git.cyclocoop.org/geomaker.php?a=commitdiff_plain;h=666d4d51358895cf141e4208ef18e8fa798ab72a;p=lhc%2Fweb%2Fwiklou.git Merge changes from 1.4: * Squid purged defered to outside the db transaction * Partial redirect goodies * Compression threadhold on memcached * setproctitle * Some other tweaks --- diff --git a/includes/Article.php b/includes/Article.php index 62f3129b18..a216fc9fd8 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 diff --git a/includes/Setup.php b/includes/Setup.php index 2d48329680..f62fda03f3 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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 ); diff --git a/index.php b/index.php index cbb51377c2..ec627961cb 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ saveMasterPos(); $wgLoadBalancer->commitAll(); $wgOut->output(); + +foreach ( $wgPostCommitUpdateList as $up ) { + $up->doUpdate(); +} + wfProfileOut( 'main-cleanup' ); logProfilingData();