changing wfQuery to allow replication
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 20 Sep 2003 03:00:34 +0000 (03:00 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 20 Sep 2003 03:00:34 +0000 (03:00 +0000)
includes/SpecialWhatlinkshere.php
includes/Title.php
includes/User.php
includes/UserTalkUpdate.php
includes/ViewCountUpdate.php
install.php
languages/Language.php

index 9eaaadf..23922fd 100644 (file)
@@ -25,7 +25,7 @@ function wfSpecialWhatlinkshere($par = NULL)
        if ( 0 == $id ) {
                $sql = "SELECT DISTINCT bl_from FROM brokenlinks WHERE bl_to='" .
                  wfStrencode( $nt->getPrefixedDBkey() ) . "' LIMIT 500";
-               $res = wfQuery( $sql, $fname );
+               $res = wfQuery( $sql, DB_READ, $fname );
 
                if ( 0 == wfNumRows( $res ) ) {
                        $wgOut->addHTML( wfMsg( "nolinkshere" ) );
@@ -37,7 +37,7 @@ function wfSpecialWhatlinkshere($par = NULL)
                                $lid = $row->bl_from;
                                $sql = "SELECT cur_namespace,cur_title,cur_is_redirect " .
                                  "FROM cur WHERE cur_id={$lid}";
-                               $res2 = wfQuery( $sql, $fname );
+                               $res2 = wfQuery( $sql, DB_READ, $fname );
                                $s = wfFetchObject( $res2 );
 
                                $n = Title::makeName( $s->cur_namespace, $s->cur_title );
@@ -64,7 +64,7 @@ function wfShowIndirectLinks( $level, $lid )
        $fname = "wfShowIndirectLinks";
 
        $sql = "SELECT DISTINCT l_from FROM links WHERE l_to={$lid} LIMIT 500";
-       $res = wfQuery( $sql, $fname );
+       $res = wfQuery( $sql, DB_READ, $fname );
 
        if ( 0 == wfNumRows( $res ) ) {
                if ( 0 == $level ) {
@@ -89,7 +89,7 @@ function wfShowIndirectLinks( $level, $lid )
 
                $sql = "SELECT cur_id,cur_is_redirect FROM cur " .
                  "WHERE cur_namespace={$ns} AND cur_title='{$t}'";
-               $res2 = wfQuery( $sql, $fname );
+               $res2 = wfQuery( $sql, DB_READ, $fname );
                $s = wfFetchObject( $res2 );
 
                if ( 1 == $s->cur_is_redirect ) {
index cbc870d..3e7d6d9 100644 (file)
@@ -72,7 +72,7 @@ class Title {
        {
                $sql = "SELECT cur_namespace,cur_title FROM cur WHERE " .
                  "cur_id={$id}";
-               $res = wfQuery( $sql, "Article::nameOf" );
+               $res = wfQuery( $sql, DB_READ, "Article::nameOf" );
                if ( 0 == wfNumRows( $res ) ) { return NULL; }
 
                $s = wfFetchObject( $res );
@@ -103,7 +103,7 @@ class Title {
                
                $dkey = wfStrencode( $key );
                $query = "SELECT iw_url FROM interwiki WHERE iw_prefix='$dkey'";
-               $res = wfQuery( $query, "Title::getInterwikiLink" );
+               $res = wfQuery( $query, DB_READ, "Title::getInterwikiLink" );
                if(!$res) return "";
                
                $s = wfFetchObject( $res );
@@ -288,7 +288,7 @@ class Title {
                $ns = $this->getNamespace();
                $t = wfStrencode( $this->getDBkey() );
                $sql = "SELECT COUNT(*) AS n FROM archive WHERE ar_namespace=$ns AND ar_title='$t'";
-               if( $res = wfQuery( $sql ) ) {
+               if( $res = wfQuery( $sql, DB_READ ) ) {
                        $s = wfFetchObject( $res );
                        return $s->n;
                }
index 2881837..091b3aa 100644 (file)
@@ -38,7 +38,7 @@ class User {
                $nt = Title::newFromText( $name );
                $sql = "SELECT user_id FROM user WHERE user_name='" .
                  wfStrencode( $nt->getText() ) . "'";
-               $res = wfQuery( $sql, "User::idFromName" );
+               $res = wfQuery( $sql, DB_READ, "User::idFromName" );
 
                if ( 0 == wfNumRows( $res ) ) { return 0; }
                else {
@@ -189,7 +189,7 @@ class User {
                $this->mNewtalk=0; # reset talk page status
                if($this->mId) {
                        $sql = "SELECT 1 FROM user_newtalk WHERE user_id={$this->mId}";
-                       $res = wfQuery ($sql,  "User::loadFromDatabase" );
+                       $res = wfQuery ($sql, DB_READ, "User::loadFromDatabase" );
 
                        if (wfNumRows($res)>0) {
                                $this->mNewtalk= 1;
@@ -201,7 +201,7 @@ class User {
                        $newtalk = $wgMemc->get( $key );
                        if($newtalk === false) {
                                $sql = "SELECT 1 FROM user_newtalk WHERE user_ip='{$this->mName}'";
-                               $res = wfQuery ($sql,  "User::loadFromDatabase" );
+                               $res = wfQuery ($sql, DB_READ "User::loadFromDatabase" );
 
                                $this->mNewtalk = (wfNumRows($res)>0) ? 1 : 0;
                                wfFreeResult( $res );
@@ -219,7 +219,7 @@ class User {
                $sql = "SELECT user_name,user_password,user_newpassword,user_email," .
                  "user_options,user_rights,user_touched FROM user WHERE user_id=" .
                  "{$this->mId}";
-               $res = wfQuery( $sql, "User::loadFromDatabase" );
+               $res = wfQuery( $sql, DB_READ, "User::loadFromDatabase" );
 
                if ( wfNumRows( $res ) > 0 ) {
                        $s = wfFetchObject( $res );
@@ -414,7 +414,7 @@ class User {
                          WHERE wl_user={$this->mId} AND
                          wl_namespace = " . ($title->getNamespace() & ~1) . " AND
                          wl_title='" . wfStrencode( $title->getDBkey() ) . "'";
-                       $res = wfQuery( $sql );
+                       $res = wfQuery( $sql, DB_READ );
                        return (wfNumRows( $res ) > 0);
                } else {
                        return false;
@@ -429,7 +429,7 @@ class User {
                        $sql = "REPLACE INTO watchlist (wl_user, wl_namespace,wl_title)
                          VALUES ({$this->mId}," . (($title->getNamespace() | 1) - 1) .
                          ",'" . wfStrencode( $title->getDBkey() ) . "')";
-                       wfQuery( $sql );
+                       wfQuery( $sql, DB_WRITE );
                        $this->invalidateCache();
                }
        }
@@ -440,7 +440,7 @@ class User {
                        $sql = "DELETE FROM watchlist WHERE wl_user={$this->mId} AND
                          wl_namespace=" . (($title->getNamespace() | 1) - 1) .
                          " AND wl_title='" . wfStrencode( $title->getDBkey() ) . "'";
-                       wfQuery( $sql );
+                       wfQuery( $sql, DB_WRITE );
             $this->invalidateCache();
                }
        }
@@ -506,10 +506,10 @@ class User {
                if ( ! $this->mNewtalk ) {
                        if( $this->mId ) {
                                $sql="DELETE FROM user_newtalk WHERE user_id={$this->mId}";
-                               wfQuery ($sql,"User::saveSettings");
+                               wfQuery ($sql, DB_WRITE, "User::saveSettings");
                        } else {
                                $sql="DELETE FROM user_newtalk WHERE user_ip='{$this->mName}'";
-                               wfQuery ($sql,"User::saveSettings");
+                               wfQuery ($sql, DB_WRITE, "User::saveSettings");
                                $wgMemc->delete( "$wgDBname:newtalk:ip:{$this->mName}" );
                        }
                }
@@ -524,7 +524,7 @@ class User {
                  "user_rights= '" . wfStrencode( implode( ",", $this->mRights ) ) . "', " .
                  "user_touched= '" . wfStrencode( $this->mTouched ) .
                  "' WHERE user_id={$this->mId}";
-               wfQuery( $sql, "User::saveSettings" );
+               wfQuery( $sql, DB_WRITE, "User::saveSettings" );
                #$wgMemc->replace( "$wgDBname:user:id:$this->mId", $this );
                $wgMemc->delete( "$wgDBname:user:id:$this->mId" );
        }
@@ -539,7 +539,7 @@ class User {
 
                $sql = "SELECT user_id FROM user WHERE user_name='" .
                  wfStrencode( $s ) . "'";
-               $res = wfQuery( $sql, "User::idForName" );
+               $res = wfQuery( $sql, DB_READ, "User::idForName" );
                if ( 0 == wfNumRows( $res ) ) { return 0; }
 
                $s = wfFetchObject( $res );
@@ -560,7 +560,7 @@ class User {
                  wfStrencode( $this->mEmail ) . "', '" .
                  wfStrencode( implode( ",", $this->mRights ) ) . "', '" .
                  $this->encodeOptions() . "')";
-               wfQuery( $sql, "User::addToDatabase" );
+               wfQuery( $sql, DB_WRITE, "User::addToDatabase" );
                $this->mId = $this->idForName();
        }
 
index 70c8486..53f3e98 100644 (file)
@@ -48,7 +48,7 @@ class UserTalkUpdate {
                                }
                                
                                if($sql && !$user->getNewtalk()) { # only insert if real user and it's not already there
-                                       wfQuery( $sql, $fname );
+                                       wfQuery( $sql, DB_WRITE, $fname );
                                }
                        }
                }
index 954c591..ba98ba7 100644 (file)
@@ -17,7 +17,7 @@ class ViewCountUpdate {
 
                $sql = "UPDATE LOW_PRIORITY cur SET cur_counter=(1+cur_counter)," .
                  "cur_timestamp=cur_timestamp WHERE cur_id={$this->mPageID}";
-               $res = wfQuery( $sql, "ViewCountUpdate::doUpdate" );
+               $res = wfQuery( $sql, DB_WRITE, "ViewCountUpdate::doUpdate" );
        }
 }
 
index 724ec24..235cc93 100644 (file)
@@ -246,14 +246,14 @@ function populatedata() {
        $fname = "Installation script: populatedata()";
 
        $sql = "DELETE FROM site_stats";
-       wfQuery( $sql, $fname );
+       wfQuery( $sql, DB_WRITE, $fname );
 
        $sql = "INSERT INTO site_stats (ss_row_id,ss_total_views," .
                "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)";
-       wfQuery( $sql, $fname );
+       wfQuery( $sql, DB_WRITE, $fname );
 
        $sql = "DELETE FROM user";
-       wfQuery( $sql, $fname );
+       wfQuery( $sql, DB_WRITE, $fname );
 
        $u = User::newFromName( "WikiSysop" );
        if ( 0 == $u->idForName() ) {
@@ -276,22 +276,22 @@ function populatedata() {
        $dlp = addslashes( wfMsg( "dellogpage" ) );
 
        $sql = "DELETE FROM cur";
-       wfQuery( $sql, $fname );
+       wfQuery( $sql, DB_WRITE, $fname );
 
        $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
          "cur_restrictions) VALUES ({$wns},'{$ulp}','" .
          wfStrencode( wfMsg( "uploadlogpagetext" ) ) . "','sysop')";
-       wfQuery( $sql );
+       wfQuery( $sql, DB_WRITE, $fname );
 
        $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
          "cur_restrictions) VALUES ({$wns},'{$dlp}','" .
          wfStrencode( wfMsg( "dellogpagetext" ) ) . "','sysop')";
-       wfQuery( $sql );
+       wfQuery( $sql, DB_WRITE, $fname );
 
        $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text) " .
          "VALUES (0,'" . wfStrencode( wfMsg( "mainpage" ) ) . "','" .
          wfStrencode( wfMsg( "mainpagetext" ) ) . "')";
-       wfQuery( $sql );
+       wfQuery( $sql, DB_WRITE, $fname );
 }
 
 ?>
index aed7e8f..144d1f5 100644 (file)
@@ -314,7 +314,7 @@ this</a> (alternative: like this<a href=\"\" class=\"internal\">?</a>).",
        "Intl"          => "Interlanguage links",
        "Allpages"              => "All pages by title",
 
-       "Ipblocklist"   => "Blocked IP addresses",
+       "Ipblocklist"   => "Blocked users/IP addresses",
        "Maintenance" => "Maintenance page",
        "Specialpages"  => "",
        "Contributions" => "",
@@ -328,7 +328,7 @@ this</a> (alternative: like this<a href=\"\" class=\"internal\">?</a>).",
 );
 
 /* private */ $wgSysopSpecialPagesEn = array(
-       "Blockip"               => "Block aIP address",
+       "Blockip"               => "Block a user/IP address",
        "Asksql"                => "Query the database",
        "Undelete"              => "Restore deleted pages"
 );