From af7840c7d8602ca332f56481b1e721ae9d2e68fd Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 20 Sep 2003 03:00:34 +0000 Subject: [PATCH] changing wfQuery to allow replication --- includes/SpecialWhatlinkshere.php | 8 ++++---- includes/Title.php | 6 +++--- includes/User.php | 24 ++++++++++++------------ includes/UserTalkUpdate.php | 2 +- includes/ViewCountUpdate.php | 2 +- install.php | 14 +++++++------- languages/Language.php | 4 ++-- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/includes/SpecialWhatlinkshere.php b/includes/SpecialWhatlinkshere.php index 9eaaadf348..23922fd206 100644 --- a/includes/SpecialWhatlinkshere.php +++ b/includes/SpecialWhatlinkshere.php @@ -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 ) { diff --git a/includes/Title.php b/includes/Title.php index cbc870db7b..3e7d6d9b18 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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; } diff --git a/includes/User.php b/includes/User.php index 2881837e99..091b3aaef3 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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(); } diff --git a/includes/UserTalkUpdate.php b/includes/UserTalkUpdate.php index 70c8486563..53f3e98ada 100644 --- a/includes/UserTalkUpdate.php +++ b/includes/UserTalkUpdate.php @@ -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 ); } } } diff --git a/includes/ViewCountUpdate.php b/includes/ViewCountUpdate.php index 954c59107d..ba98ba75c4 100644 --- a/includes/ViewCountUpdate.php +++ b/includes/ViewCountUpdate.php @@ -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" ); } } diff --git a/install.php b/install.php index 724ec24125..235cc934bc 100644 --- a/install.php +++ b/install.php @@ -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 ); } ?> diff --git a/languages/Language.php b/languages/Language.php index aed7e8f8bd..144d1f5795 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -314,7 +314,7 @@ this (alternative: like this?).", "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 (alternative: like this?).", ); /* private */ $wgSysopSpecialPagesEn = array( - "Blockip" => "Block an IP address", + "Blockip" => "Block a user/IP address", "Asksql" => "Query the database", "Undelete" => "Restore deleted pages" ); -- 2.20.1