From 9b28aa9905556af87942ba3ee4db5fab087fa974 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 20 Sep 2003 02:21:40 +0000 Subject: [PATCH] changing wfQuery to allow replication --- includes/SpecialLongpages.php | 2 +- includes/SpecialMaintenance.php | 14 +++---- includes/SpecialMovepage.php | 50 ++++++++++++------------- includes/SpecialNewpages.php | 2 +- includes/SpecialPopularpages.php | 2 +- includes/SpecialRandompage.php | 2 +- includes/SpecialRecentchanges.php | 6 +-- includes/SpecialRecentchangeslinked.php | 2 +- includes/SpecialShortpages.php | 2 +- includes/SpecialStatistics.php | 8 ++-- includes/SpecialUndelete.php | 16 ++++---- includes/SpecialUnusedimages.php | 2 +- includes/SpecialWantedpages.php | 2 +- 13 files changed, 55 insertions(+), 55 deletions(-) diff --git a/includes/SpecialLongpages.php b/includes/SpecialLongpages.php index e1996138ad..2203f5a17f 100644 --- a/includes/SpecialLongpages.php +++ b/includes/SpecialLongpages.php @@ -21,7 +21,7 @@ function wfSpecialLongpages() $sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " . "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " . "LENGTH(cur_text) DESC LIMIT {$offset}, {$limit}"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $sk = $wgUser->getSkin(); diff --git a/includes/SpecialMaintenance.php b/includes/SpecialMaintenance.php index 0e3f180e73..37b587549e 100644 --- a/includes/SpecialMaintenance.php +++ b/includes/SpecialMaintenance.php @@ -109,7 +109,7 @@ function wfSpecialDisambiguations() . " AND d.cur_namespace=0" . " LIMIT {$offset}, {$limit}"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $sk = $wgUser->getSkin(); @@ -145,7 +145,7 @@ function wfSpecialDoubleRedirects() $sql = "SELECT l_from,l_to,cb.cur_text AS rt,cb.cur_title AS ti FROM links,cur AS ca, cur AS cb WHERE ca.cur_is_redirect=1 AND cb.cur_is_redirect=1 AND l_to=cb.cur_id AND l_from=ca.cur_title AND ca.cur_namespace=0 LIMIT {$offset}, {$limit}" ; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $top = getMaintenancePageBacklink(); $top .= "

".wfMsg("doubleredirectstext")."


\n"; @@ -181,7 +181,7 @@ function wfSpecialBrokenRedirects() $sql = "SELECT bl_to,cur_title FROM brokenlinks,cur WHERE cur_is_redirect=1 AND cur_namespace=0 AND bl_from=cur_id LIMIT {$offset}, {$limit}" ; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $top = getMaintenancePageBacklink(); $top .= "

".wfMsg("brokenredirectstext")."


\n"; @@ -215,7 +215,7 @@ function wfSpecialSelfLinks() $sql = "SELECT cur_title FROM cur,links WHERE cur_is_redirect=0 AND cur_namespace=0 AND l_from=cur_title AND l_to=cur_id LIMIT {$offset}, {$limit}"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $top = getMaintenancePageBacklink(); $top .= "

".wfMsg("selflinkstext")."


\n"; @@ -252,7 +252,7 @@ function wfSpecialMispeelings () # Load list from database $sql = "SELECT cur_text FROM cur WHERE cur_title='{$mss}' AND cur_namespace=4" ; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $obj = wfFetchObject ( $res ) ; $l = $obj->cur_text ; $l = explode ( "\n" , $l ) ; @@ -270,7 +270,7 @@ function wfSpecialMispeelings () $x = preg_replace( '/^(\S+).*$/', '$1', $x ); #$sql = "SELECT DISTINCT cur_title FROM cur WHERE cur_namespace=0 AND cur_is_redirect=0 AND (MATCH(cur_ind_text) AGAINST ('" . wfStrencode( $wgLang->stripForSearch( $x ) ) . "'))" ; $sql = "SELECT DISTINCT cur_title FROM cur,searchindex WHERE cur_id=si_page AND cur_namespace=0 AND cur_is_redirect=0 AND (MATCH(si_text) AGAINST ('" . wfStrencode( $wgLang->stripForSearch( $x ) ) . "'))" ; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); while ( $obj = wfFetchObject ( $res ) ) { if ( $cnt >= $offset AND $cnt < $offset+$limit ) { if ( $y != "" ) { @@ -315,7 +315,7 @@ function wfSpecialMissingLanguageLinks() $sql = "SELECT cur_title FROM cur WHERE cur_namespace=0 AND cur_is_redirect=0 AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[{$thelang}:%' LIMIT {$offset}, {$limit}"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $mll = wfMsg("missinglanguagelinkstext"); diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index eb8fbc2eac..3b77ac3ef0 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -236,7 +236,7 @@ class MovePageForm { $sql = "SELECT cur_is_redirect,cur_text FROM cur " . "WHERE cur_id={$this->newid}"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $obj = wfFetchObject( $res ); if ( 0 == $obj->cur_is_redirect ) { return false; } @@ -250,7 +250,7 @@ class MovePageForm { } $sql = "SELECT old_id FROM old WHERE old_namespace={$this->nns} " . "AND old_title='{$this->ndt}'"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); if ( 0 != wfNumRows( $res ) ) { return false; } return true; @@ -269,7 +269,7 @@ class MovePageForm { $sql = "UPDATE cur SET cur_touched='{$now}'," . "cur_namespace={$this->nns},cur_title='{$this->ndt}' " . "WHERE cur_id={$this->oldid}"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE cur SET cur_touched='{$now}'," . "cur_namespace={$this->ons},cur_title='{$this->odt}'," . @@ -278,17 +278,17 @@ class MovePageForm { "',cur_minor_edit=0,cur_counter=0,cur_restrictions=''," . "cur_user_text='" . wfStrencode( $wgUser->getName() ) . "'," . "cur_is_redirect=1,cur_is_new=0 WHERE cur_id={$this->newid}"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE old SET " . "old_namespace={$this->nns},old_title='{$this->ndt}' WHERE " . "old_namespace={$this->ons} AND old_title='{$this->odt}'"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE recentchanges SET ". "rc_namespace={$this->nns}, rc_title='{$this->ndt}' WHERE ". "rc_cur_id={$this->oldid}"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "INSERT INTO recentchanges (rc_namespace,rc_title, rc_comment,rc_user,rc_user_text,rc_timestamp, @@ -297,35 +297,35 @@ class MovePageForm { "'{$mt} \\\"{$this->nft}\\\"','" . $wgUser->getID() . "','" . wfStrencode( $wgUser->getName() ) . "','{$now}','{$now}',{$this->newid},1)"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); # The only link from here should be the old redirect $sql = "DELETE FROM links WHERE l_from='{$this->nft}'"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE links SET l_from='{$this->nft}' WHERE l_from='{$this->oft}'"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); # Swap links. Using MAXINT as a temp; if there's ever an article # with id 4294967295, this will fail, but I think that's pretty safe $sql = "UPDATE links SET l_to=4294967295 WHERE l_to={$this->oldid}"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE links SET l_to={$this->oldid} WHERE l_to={$this->newid}"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE links SET l_to={$this->newid} WHERE l_to=4294967295"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); # Note: the insert below must be after the updates above! $sql = "INSERT INTO links (l_from,l_to) VALUES ('{$this->oft}',{$this->oldid})"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE imagelinks SET il_from='{$this->nft}' WHERE il_from='{$this->oft}'"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); } # Move page to non-existing title. @@ -341,7 +341,7 @@ class MovePageForm { $sql = "UPDATE cur SET cur_touched='{$now}'," . "cur_namespace={$this->nns},cur_title='{$this->ndt}' " . "WHERE cur_id={$this->oldid}"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $common = "{$this->ons},'{$this->odt}'," . "'{$mt} \\\"{$this->nft}\\\"','" . @@ -351,33 +351,33 @@ class MovePageForm { "cur_comment,cur_user,cur_user_text,cur_timestamp,inverse_timestamp," . "cur_touched,cur_text,cur_is_redirect,cur_is_new) " . "VALUES ({$common},'{$won}','{$now}','#REDIRECT [[{$this->nft}]]\n',1,1)"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $this->newid = wfInsertId(); $sql = "UPDATE old SET " . "old_namespace={$this->nns},old_title='{$this->ndt}' WHERE " . "old_namespace={$this->ons} AND old_title='{$this->odt}'"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE recentchanges SET ". "rc_namespace={$this->nns}, rc_title='{$this->ndt}' WHERE ". "rc_namespace={$this->ons} AND rc_title='{$this->odt}'"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "INSERT INTO recentchanges (rc_namespace,rc_title, rc_comment,rc_user,rc_user_text,rc_timestamp, rc_cur_time,rc_cur_id,rc_new) VALUES ({$common},'{$now}',{$this->newid},1)"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE links SET l_from='{$this->nft}' WHERE l_from='{$this->oft}'"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "UPDATE links SET l_to={$this->newid} WHERE l_to={$this->oldid}"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); $sql = "INSERT INTO links (l_from,l_to) VALUES ('{$this->oft}',{$this->oldid})"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); # Non-existent target may have had broken links to it; these must # now be removed and made into good links. @@ -385,7 +385,7 @@ class MovePageForm { $update->fixBrokenLinks(); $sql = "UPDATE imagelinks SET il_from='{$this->nft}' WHERE il_from='{$this->oft}'"; - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); } function updateWatchlists() @@ -400,14 +400,14 @@ class MovePageForm { $sql = "SELECT wl_user FROM watchlist WHERE wl_namespace={$oldnamespace} AND wl_title='{$oldtitle}'"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); if( $s = wfFetchObject( $res ) ) { $sql = "REPLACE INTO watchlist (wl_user,wl_namespace,wl_title) VALUES ({$s->wl_user},{$newnamespace},'{$newtitle}')"; while( $s = wfFetchObject( $res ) ) { $sql .= ",({$s->wl_user},{$newnamespace},'{$newtitle}')"; } - wfQuery( $sql, $fname ); + wfQuery( $sql, DB_WRITE, $fname ); } } diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index ff3ece98b5..3d0dc43cd5 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -11,7 +11,7 @@ function wfSpecialNewpages() "rc_timestamp AS cur_timestamp,length(cur_text) as cur_length FROM recentchanges,cur " . "WHERE rc_cur_id=cur_id AND rc_new=1 AND rc_namespace=0 AND cur_is_redirect=0 " . "ORDER BY rc_timestamp DESC LIMIT {$offset}, {$limit}"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $top = wfShowingResults( $offset, $limit ); $wgOut->addHTML( "

{$top}\n" ); diff --git a/includes/SpecialPopularpages.php b/includes/SpecialPopularpages.php index 628a528e45..303a909f57 100644 --- a/includes/SpecialPopularpages.php +++ b/includes/SpecialPopularpages.php @@ -16,7 +16,7 @@ function wfSpecialPopularpages() $sql = "SELECT DISTINCT cur_title, cur_counter FROM cur " . "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " . "cur_counter DESC LIMIT {$offset}, {$limit}"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $sk = $wgUser->getSkin(); diff --git a/includes/SpecialRandompage.php b/includes/SpecialRandompage.php index 9eadd041f0..00b3ac0c12 100644 --- a/includes/SpecialRandompage.php +++ b/includes/SpecialRandompage.php @@ -15,7 +15,7 @@ function wfSpecialRandompage() AND cur_random>$randstr ORDER BY cur_random LIMIT 1"; - $res = wfQuery( $sqlget, $fname ); + $res = wfQuery( $sqlget, DB_READ, $fname ); if( $s = wfFetchObject( $res ) ) { $rt = wfUrlEncode( $s->cur_title ); } else { diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 70ea460f1d..c0fa2ca88d 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -15,7 +15,7 @@ function wfSpecialRecentchanges( $par ) } $sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $s = wfFetchObject( $res ); $wgOut->checkLastModified( $s->lastmod ); @@ -23,7 +23,7 @@ function wfSpecialRecentchanges( $par ) # The next few lines can probably be commented out now that wfMsg can get text from the DB $sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text != "" ) ) { $rctext = $s->cur_text; } @@ -72,7 +72,7 @@ function wfSpecialRecentchanges( $par ) ($uid ? "LEFT OUTER JOIN watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace & 65534 " : "") . "WHERE rc_timestamp > '{$cutoff}' {$hidem} " . "ORDER BY rc_timestamp DESC LIMIT {$limit}"; - $res = wfQuery( $sql2, $fname ); + $res = wfQuery( $sql2, DB_READ, $fname ); if(isset($from)) { $note = wfMsg( "rcnotefrom", $limit, diff --git a/includes/SpecialRecentchangeslinked.php b/includes/SpecialRecentchangeslinked.php index cb5f69e31a..6dd6952784 100644 --- a/includes/SpecialRecentchangeslinked.php +++ b/includes/SpecialRecentchangeslinked.php @@ -51,7 +51,7 @@ function wfSpecialRecentchangeslinked( $par = NULL ) "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from='" . wfStrencode( $nt->getPrefixedDBkey() ) . "' GROUP BY cur_id " . "ORDER BY inverse_timestamp LIMIT {$limit}"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $note = wfMsg( "rcnote", $limit, $days ); $wgOut->addHTML( "


\n{$note}\n
" ); diff --git a/includes/SpecialShortpages.php b/includes/SpecialShortpages.php index ffdd65fb0f..deb3824515 100644 --- a/includes/SpecialShortpages.php +++ b/includes/SpecialShortpages.php @@ -21,7 +21,7 @@ function wfSpecialShortpages() $sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " . "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " . "LENGTH(cur_text) LIMIT {$offset}, {$limit}"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $top = wfShowingResults( $offset, $limit ); $wgOut->addHTML( "

{$top}\n" ); diff --git a/includes/SpecialStatistics.php b/includes/SpecialStatistics.php index 8c4335ffdc..35c4f215d4 100644 --- a/includes/SpecialStatistics.php +++ b/includes/SpecialStatistics.php @@ -8,13 +8,13 @@ function wfSpecialStatistics() $wgOut->addHTML( "

" . wfMsg( "sitestats" ) . "

\n" ); $sql = "SELECT COUNT(cur_id) AS total FROM cur"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $row = wfFetchObject( $res ); $total = $row->total; $sql = "SELECT ss_total_views, ss_total_edits, ss_good_articles " . "FROM site_stats WHERE ss_row_id=1"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $row = wfFetchObject( $res ); $views = $row->ss_total_views; $edits = $row->ss_total_edits; @@ -31,13 +31,13 @@ function wfSpecialStatistics() $wgOut->addHTML( "

" . wfMsg( "userstats" ) . "

\n" ); $sql = "SELECT COUNT(user_id) AS total FROM user"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $row = wfFetchObject( $res ); $total = $row->total; $sql = "SELECT COUNT(user_id) AS total FROM user " . "WHERE user_rights LIKE '%sysop%'"; - $res = wfQuery( $sql, $fname ); + $res = wfQuery( $sql, DB_READ, $fname ); $row = wfFetchObject( $res ); $admins = $row->total; diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 0c19aae64d..116ec67901 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -20,7 +20,7 @@ function wfSpecialUndelete( $par ) # List undeletable articles $sql = "SELECT ar_namespace,ar_title, COUNT(*) AS count FROM archive GROUP BY ar_namespace,ar_title ORDER BY ar_title"; - $res = wfQuery( $sql ); + $res = wfQuery( $sql, DB_READ ); $wgOut->setPagetitle( wfMsg( "undeletepage" ) ); $wgOut->addWikiText( wfMsg( "undeletepagetext" ) ); @@ -49,7 +49,7 @@ function wfSpecialUndelete( $par ) if(!preg_match("/[0-9]{14}/",$timestamp)) return 0; $sql = "SELECT ar_text FROM archive WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\" AND ar_timestamp={$timestamp}"; - $ret = wfQuery( $sql ); + $ret = wfQuery( $sql, DB_READ ); $row = wfFetchObject( $ret ); $wgOut->setPagetitle( wfMsg( "undeletepage" ) ); @@ -84,7 +84,7 @@ function wfSpecialUndelete( $par ) $sql = "SELECT ar_minor_edit,ar_timestamp,ar_user,ar_user_text,ar_comment FROM archive WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\" ORDER BY ar_timestamp DESC"; - $ret = wfQuery( $sql ); + $ret = wfQuery( $sql, DB_READ ); $special = $wgLang->getNsText( Namespace::getSpecial() ); $wgOut->addHTML("