Load balancing enabled in places where it's thought to be reasonably safe
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 10 Jul 2004 01:05:36 +0000 (01:05 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 10 Jul 2004 01:05:36 +0000 (01:05 +0000)
includes/Article.php
includes/Block.php
includes/SearchEngine.php
includes/Skin.php
includes/SpecialAllpages.php
includes/SpecialMaintenance.php
includes/SpecialStatistics.php
includes/SpecialWatchlist.php
includes/Title.php

index 748bcec..1af07e3 100644 (file)
@@ -313,7 +313,7 @@ class Article {
        # Load the revision (including cur_text) into this object
        function loadContent( $noredir = false )
        {
-               global $wgOut, $wgMwRedir, $wgRequest, $wgIsPg;
+               global $wgOut, $wgMwRedir, $wgRequest, $wgIsPg, $wgLoadBalancer;
 
                # Query variables :P
                $oldid = $wgRequest->getVal( 'oldid' );
@@ -397,11 +397,13 @@ class Article {
                        $this->mTitle->mRestrictionsLoaded = true;
                        wfFreeResult( $res );
                } else { # oldid set, retrieve historical version
+                       $wgLoadBalancer->force(-1);
                        $oldtable=$wgIsPg?'"old"':'old';
                        $sql = "SELECT old_namespace,old_title,old_text,old_timestamp,".
                                "old_user,old_user_text,old_comment,old_flags FROM old ".
                                "WHERE old_id={$oldid}";
                        $res = wfQuery( $sql, DB_READ, $fname );
+                       $wgLoadBalancer->force(0);
                        if ( 0 == wfNumRows( $res ) ) {
                                return;
                        }
index e8a53e0..e5df262 100644 (file)
@@ -45,7 +45,8 @@ class Block
        # Get a ban from the DB, with either the given address or the given username
        function load( $address = "", $user = 0, $killExpired = true ) 
        {
-               $fname = 'Block::load';
+               global $wgLoadBalancer;
+                $fname = 'Block::load';
                $ret = false;
                $killed = false;
                
@@ -60,8 +61,10 @@ class Block
                                "' OR ipb_user={$user})";
                }
 
-               $res = wfQuery( $sql, DB_READ, $fname );
-               if ( 0 == wfNumRows( $res ) ) {
+               $wgLoadBalancer->force(-1);
+                $res = wfQuery( $sql, DB_READ, $fname );
+               $wgLoadBalancer->force(0);
+                if ( 0 == wfNumRows( $res ) ) {
                        # User is not blocked
                        $this->clear();
                } else {
index 53d9e69..ff17c89 100644 (file)
@@ -157,7 +157,11 @@ class SearchEngine {
        {
                global $wgUser, $wgTitle, $wgOut, $wgLang, $wgRequest;
                global $wgDisableTextSearch, $wgInputEncoding;
-               $fname = "SearchEngine::showResults";
+               global $wgLoadBalancer;
+                               
+                $wgLoadBalancer->force(-1);
+
+                $fname = "SearchEngine::showResults";
 
                $search = $wgRequest->getText( 'search' );
 
@@ -280,7 +284,8 @@ class SearchEngine {
                        $wgOut->addHTML( "<p>{$sl}</p>\n" );
                        $wgOut->addHTML( $powersearch );
                }
-       }
+               $wgLoadBalancer->force(0);
+        }
 
        function legalSearchChars()
        {
index 866ee65..a8df31c 100644 (file)
@@ -12,7 +12,7 @@ require_once( 'Image.php' );
        'standard'              => 'Standard',
        'nostalgia'             => 'Nostalgia',
        'cologneblue'   => 'CologneBlue'
-);
+) + $wgExtraSkins;
 if( $wgUsePHPTal ) {
     #$wgValidSkinNames[] = 'PHPTal';
     #$wgValidSkinNames['davinci'] = 'DaVinci';
@@ -1440,7 +1440,7 @@ class Skin {
        # Pass a title object, not a title string
        function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' )
        {
-               global $wgOut, $wgUser;
+               global $wgOut, $wgUser, $wgLoadBalancer;
                if ( $nt->isExternal() ) {
                        $u = $nt->getFullURL();
                        $link = $nt->getPrefixedURL();
@@ -1467,8 +1467,9 @@ class Skin {
                        } else {
                                $threshold = $wgUser->getOption('stubthreshold') ;
                                if ( $threshold > 0 ) {
-                                       $res = wfQuery ( "SELECT LENGTH(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'", DB_READ ) ;
-
+                                       $wgLoadBalancer->force(-1);
+                                       $res = wfQuery ( "SELECT LENGTH(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'", DB_READ ) ;
+                                       $wgLoadBalancer->force(0);
                                        if ( wfNumRows( $res ) > 0 ) {
                                                $s = wfFetchObject( $res );
                                                $size = $s->x;
index d848880..1cdeaa7 100644 (file)
@@ -2,9 +2,11 @@
 
 function wfSpecialAllpages( $par=NULL )
 {
-       global $indexMaxperpage, $wgRequest;
+       global $indexMaxperpage, $wgRequest, $wgLoadBalancer;
        $indexMaxperpage = 480;
        $from = $wgRequest->getVal( 'from' );
+       
+       $wgLoadBalancer->force(-1);
 
        if( $par ) {
                indexShowChunk( $par );
@@ -13,6 +15,8 @@ function wfSpecialAllpages( $par=NULL )
        } else {
                indexShowToplevel();
        }
+
+       $wgLoadBalancer->force(0);
 }
 
 function indexShowToplevel()
index e6e75a2..3b16d6a 100644 (file)
@@ -10,13 +10,15 @@ function sns()
 function wfSpecialMaintenance( $par=NULL )
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle, $wgRequest, $wgLanguageCode;
-       global $wgMiserMode;
+       global $wgMiserMode, $wgLoadBalancer;
 
        if ( $wgMiserMode ) {
                $wgOut->addWikiText( wfMsg( "perfdisabled" ) );
                return;
        }
        
+       $wgLoadBalancer->force(-1);
+
        $submitmll = $wgRequest->getVal( 'submitmll' );
        
        if( $par )
@@ -24,13 +26,30 @@ function wfSpecialMaintenance( $par=NULL )
        else
                $subfunction = $wgRequest->getText( 'subfunction' );
 
-       if ( $subfunction == "disambiguations" ) return wfSpecialDisambiguations() ;
-       if ( $subfunction == "doubleredirects" ) return wfSpecialDoubleRedirects() ;
-       if ( $subfunction == "brokenredirects" ) return wfSpecialBrokenRedirects() ;
-       if ( $subfunction == "selflinks" ) return wfSpecialSelfLinks() ;
-        if ( $subfunction == "mispeelings" ) return wfSpecialMispeelings() ;
-       if ( $subfunction == "missinglanguagelinks" ) return wfSpecialMissingLanguageLinks() ;
-       if ( !is_null( $submitmll ) ) return wfSpecialMissingLanguageLinks() ;
+       $done = true;
+
+       if ( $subfunction == "disambiguations" ) {
+               wfSpecialDisambiguations() ;
+       } elseif ( $subfunction == "doubleredirects" ) {
+               wfSpecialDoubleRedirects() ;
+       } elseif ( $subfunction == "brokenredirects" ) {
+               wfSpecialBrokenRedirects() ;
+       } elseif ( $subfunction == "selflinks" ) {
+               wfSpecialSelfLinks() ;
+       } elseif ( $subfunction == "mispeelings" ) {
+               wfSpecialMispeelings() ;
+       } elseif ( $subfunction == "missinglanguagelinks" ) {
+          wfSpecialMissingLanguageLinks() ;
+       } elseif ( !is_null( $submitmll ) ) {
+               wfSpecialMissingLanguageLinks() ;
+       } else {
+               $done = false;
+       }
+       
+       $wgLoadBalancer->force(0);
+       if ( $done ) {
+               return;
+       }
 
        $sk = $wgUser->getSkin();
        $ns = $wgLang->getNamespaces() ;
index b842e52..f53cebc 100644 (file)
@@ -2,9 +2,11 @@
 
 function wfSpecialStatistics()
 {
-       global $wgUser, $wgOut, $wgLang, $wgIsPg;
+       global $wgUser, $wgOut, $wgLang, $wgIsPg, $wgLoadBalancer;
        $fname = "wfSpecialStatistics";
 
+       $wgLoadBalancer->force(-1);
+
        $wgOut->addHTML( "<h2>" . wfMsg( "sitestats" ) . "</h2>\n" );
 
        $sql = "SELECT COUNT(cur_id) AS total FROM cur";
@@ -50,6 +52,8 @@ function wfSpecialStatistics()
                $wgLang->formatNum( $total ),
                $wgLang->formatNum( $admins ), $ap );
        $wgOut->addWikiText( $text );
+
+       $wgLoadBalancer->force(0);
 }
 
 ?>
index 806eff0..aece38b 100644 (file)
@@ -4,7 +4,7 @@ require_once( "WatchedItem.php" );
 
 function wfSpecialWatchlist()
 {
-       global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc;
+       global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgLoadBalancer;
        global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname, $wgIsMySQL;
        global $days, $limit, $target; # From query string
        $fname = "wfSpecialWatchlist";
@@ -50,18 +50,20 @@ function wfSpecialWatchlist()
                        return;
                }
        }
-
-
+       
+       $wgLoadBalancer->force(-1);
        $sql = "SELECT COUNT(*) AS n FROM watchlist WHERE wl_user=$uid";
        $res = wfQuery( $sql, DB_READ );
        $s = wfFetchObject( $res );
        $nitems = $s->n;
-       
+       $wgLoadBalancer->force(0);
        if($nitems == 0) {
         $wgOut->addHTML( wfMsg( "nowatchlist" ) );
         return;
        }
-
+       
+       $wgLoadBalancer->force(-1);
+       
        if ( ! isset( $days ) ) {
                $big = 1000;
                if($nitems > $big) {
@@ -79,13 +81,14 @@ function wfSpecialWatchlist()
                $cutoff = false;
                $npages = wfMsg( "all" );
        } else {
-               $docutoff = "AND cur_timestamp > '" .
+               $docutoff = "AND cur_timestamp > '" .
                  ( $cutoff = wfUnix2Timestamp( time() - intval( $days * 86400 ) ) )
                  . "'";
-               $sql = "SELECT COUNT(*) AS n FROM cur WHERE cur_timestamp>'$cutoff'";
+               $sql = "SELECT COUNT(*) AS n FROM cur WHERE cur_timestamp>'$cutoff'";
                $res = wfQuery( $sql, DB_READ );
                $s = wfFetchObject( $res );
                $npages = $s->n;
+               
        }
        
        if(isset($_REQUEST['magic'])) {
@@ -116,6 +119,7 @@ function wfSpecialWatchlist()
                        wfMsg( "removechecked" ) . "' />\n" .
                        "</form>\n" );
                
+               $wgLoadBalancer->force(0);
                return;
        }
        
@@ -167,6 +171,7 @@ function wfSpecialWatchlist()
 
        if ( wfNumRows( $res ) == 0 ) {
                $wgOut->addHTML( "<p><i>" . wfMsg( "watchnochange" ) . "</i></p>" );
+               $wgLoadBalancer->force(0);
                return;
        }
 
@@ -187,6 +192,8 @@ function wfSpecialWatchlist()
        if ( $wgUseWatchlistCache ) {
                $wgMemc->set( $memckey, $s, $wgWLCacheTimeout);
        }
+       
+       $wgLoadBalancer->force(0);
 }
 
 
index d54c0a9..7acdc61 100644 (file)
@@ -244,7 +244,8 @@ class Title {
        function getInterwikiLink( $key )
        {       
                global $wgMemc, $wgDBname, $wgInterwikiExpiry, $wgTitleInterwikiCache;
-
+                global $wgLoadBalancer;
+                
                $k = "$wgDBname:interwiki:$key";
 
                if( array_key_exists( $k, $wgTitleInterwikiCache ) )
@@ -257,9 +258,11 @@ class Title {
                        return $s->iw_url;
                }
                $dkey = wfStrencode( $key );
-               $query = "SELECT iw_url,iw_local FROM interwiki WHERE iw_prefix='$dkey'";
+               $wgLoadBalancer->force(-1);
+                $query = "SELECT iw_url,iw_local FROM interwiki WHERE iw_prefix='$dkey'";
                $res = wfQuery( $query, DB_READ, "Title::getInterwikiLink" );
-               if(!$res) return "";
+               $wgLoadBalancer->force(0);
+                if(!$res) return "";
                
                $s = wfFetchObject( $res );
                if(!$s) {