More wfQuery() conversion
This commit is contained in:
parent
7e87e13715
commit
b32d1ece40
7 changed files with 49 additions and 48 deletions
|
|
@ -817,7 +817,7 @@ class Article {
|
|||
if ( 0 != $id ) {
|
||||
$t = wfStrencode( $title->getPrefixedDBkey() );
|
||||
$sql = "SELECT l_from FROM links WHERE l_to={$id}";
|
||||
$res = wfQuery( $sql, DB_WRITE, $fname );
|
||||
$res = wfQuery( $sql, DB_READ, $fname );
|
||||
|
||||
$sql = "INSERT INTO brokenlinks (bl_from,bl_to) VALUES ";
|
||||
$now = wfTimestampNow();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ include_once( "$IP/CacheManager.php" );
|
|||
|
||||
define( "DB_READ", -1 );
|
||||
define( "DB_WRITE", -2 );
|
||||
define( "DB_LAST", -3 );
|
||||
|
||||
$wgLastDatabaseQuery = "";
|
||||
|
||||
|
|
@ -141,7 +142,7 @@ function wfSetSQL( $table, $var, $value, $cond )
|
|||
function wfGetSQL( $table, $var, $cond )
|
||||
{
|
||||
$sql = "SELECT $var FROM $table WHERE ($cond)";
|
||||
$result = wfQuery( $sql, DB_WRITE, "wfGetSQL" );
|
||||
$result = wfQuery( $sql, DB_READ, "wfGetSQL" );
|
||||
|
||||
$ret = "";
|
||||
if ( mysql_num_rows( $result ) > 0 ) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class SqlQueryForm {
|
|||
$connection = wfGetDB( $wgDBsqluser, $wgDBsqlpassword );
|
||||
}
|
||||
$this->logQuery( $wpSqlQuery );
|
||||
$res = wfQuery( $wpSqlQuery, DB_READ, "SpecialAsksql::doSubmit" );
|
||||
$res = wfQuery( $wpSqlQuery, DB_WRITE, "SpecialAsksql::doSubmit" );
|
||||
$this->logFinishedQuery();
|
||||
|
||||
$n = 0;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function page2xml( $page, $curonly, $full = false ) {
|
|||
$sql = "SELECT cur_id as id,cur_timestamp as timestamp,cur_user as user,cur_user_text as user_text," .
|
||||
"cur_restrictions as restrictions,cur_comment as comment,cur_text as text FROM cur " .
|
||||
"WHERE cur_namespace=$ns AND cur_title='$t'";
|
||||
$res = wfQuery( $sql );
|
||||
$res = wfQuery( $sql, DB_READ );
|
||||
if( $s = wfFetchObject( $res ) ) {
|
||||
$tl = htmlspecialchars( $title->getPrefixedText() );
|
||||
$xml = " <page>\n";
|
||||
|
|
@ -66,7 +66,7 @@ function page2xml( $page, $curonly, $full = false ) {
|
|||
$sql = "SELECT old_id as id,old_timestamp as timestamp, old_user as user, old_user_text as user_text," .
|
||||
"old_comment as comment, old_text as text FROM old " .
|
||||
"WHERE old_namespace=$ns AND old_title='$t' ORDER BY old_timestamp";
|
||||
$res = wfQuery( $sql );
|
||||
$res = wfQuery( $sql, DB_READ );
|
||||
|
||||
while( $s = wfFetchObject( $res ) ) {
|
||||
$xml .= revision2xml( $s, $full, false );
|
||||
|
|
|
|||
|
|
@ -63,14 +63,14 @@ function convertUserTable()
|
|||
print "Converting USER table.\n";
|
||||
|
||||
$sql = "LOCK TABLES old_user READ, user WRITE";
|
||||
$newres = wfQuery( $sql );
|
||||
$newres = wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$sql = "SELECT user_id,user_name,user_rights,user_password," .
|
||||
"user_email,user_options,user_watch FROM old_user";
|
||||
$oldres = wfQuery( $sql );
|
||||
$oldres = wfQuery( $sql, DB_READ );
|
||||
|
||||
$sql = "DELETE FROM user";
|
||||
$newres = wfQuery( $sql );
|
||||
$newres = wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$sql = "";
|
||||
while ( $row = mysql_fetch_object( $oldres ) ) {
|
||||
|
|
@ -78,7 +78,7 @@ function convertUserTable()
|
|||
if ( "" == $name ) continue; # Don't convert illegal names
|
||||
|
||||
if ( 0 == ( $count % 10 ) ) {
|
||||
if ( 0 != $count ) { $newres = wfQuery( $sql ); }
|
||||
if ( 0 != $count ) { $newres = wfQuery( $sql, DB_WRITE ); }
|
||||
|
||||
$sql = "INSERT INTO user (user_id,user_name,user_rights," .
|
||||
"user_password,user_newpassword,user_email,user_options," .
|
||||
|
|
@ -99,13 +99,13 @@ function convertUserTable()
|
|||
print "$count user records processed.\n";
|
||||
}
|
||||
}
|
||||
if ( $sql ) { $newres = wfQuery( $sql ); }
|
||||
if ( $sql ) { $newres = wfQuery( $sql, DB_WRITE ); }
|
||||
|
||||
print "$count user records processed.\n";
|
||||
mysql_free_result( $oldres );
|
||||
|
||||
$sql = "UNLOCK TABLES";
|
||||
$newres = wfQuery( $sql );
|
||||
$newres = wfQuery( $sql, DB_WRITE );
|
||||
}
|
||||
|
||||
# Convert May 2002 version of database into new format.
|
||||
|
|
@ -116,18 +116,18 @@ function convertCurTable()
|
|||
print "Converting CUR table.\n";
|
||||
|
||||
$sql = "LOCK TABLES old_cur READ, cur WRITE, site_stats WRITE";
|
||||
$newres = wfQuery( $sql );
|
||||
$newres = wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$sql = "SELECT cur_id,cur_title,cur_text,cur_comment,cur_user," .
|
||||
"cur_timestamp,cur_minor_edit,cur_restrictions," .
|
||||
"cur_counter,cur_ind_title,cur_user_text FROM old_cur";
|
||||
$oldres = wfQuery( $sql );
|
||||
$oldres = wfQuery( $sql, DB_READ );
|
||||
|
||||
$sql = "DELETE FROM cur";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$sql = "DELETE FROM site_stats";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$sql = "";
|
||||
while ( $row = mysql_fetch_object( $oldres ) ) {
|
||||
|
|
@ -166,7 +166,7 @@ function convertCurTable()
|
|||
"'{$com}',{$row->cur_user},'{$row->cur_timestamp}'," .
|
||||
"{$isme},{$isnew},'{$cr}',0,'{$ititle}','{$itext}'," .
|
||||
"{$redir},'{$cut}')";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
|
||||
if ( ( ++$count % 1000 ) == 0 ) {
|
||||
print "$count article records processed.\n";
|
||||
|
|
@ -181,10 +181,10 @@ function convertCurTable()
|
|||
|
||||
$sql = "REPLACE INTO site_stats (ss_row_id,ss_total_views," .
|
||||
"ss_total_edits,ss_good_articles) VALUES (1,0,0,{$countables})";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$sql = "UNLOCK TABLES";
|
||||
$newres = wfQuery( $sql );
|
||||
$newres = wfQuery( $sql, DB_WRITE );
|
||||
}
|
||||
|
||||
# Convert May 2002 version of database into new format.
|
||||
|
|
@ -195,14 +195,14 @@ function convertOldTable()
|
|||
print "Converting OLD table.\n";
|
||||
|
||||
$sql = "LOCK TABLES old_old READ, old WRITE";
|
||||
$newres = wfQuery( $sql );
|
||||
$newres = wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$sql = "SELECT old_id,old_title,old_text,old_comment,old_user," .
|
||||
"old_timestamp,old_minor_edit,old_user_text FROM old_old";
|
||||
$oldres = wfQuery( $sql );
|
||||
$oldres = wfQuery( $sql, DB_READ );
|
||||
|
||||
$sql = "DELETE FROM old";
|
||||
$newres = wfQuery( $sql );
|
||||
$newres = wfQuery( $sql, DB_WRITE );
|
||||
|
||||
while ( $row = mysql_fetch_object( $oldres ) ) {
|
||||
$nt = Title::newFromDBkey( $row->old_title );
|
||||
|
|
@ -231,7 +231,7 @@ function convertOldTable()
|
|||
$sql .= "({$row->old_id},{$ns},'{$title}','{$text}'," .
|
||||
"'{$com}',{$row->old_user},'{$row->old_timestamp}'," .
|
||||
"{$isme},'{$cut}')";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
|
||||
if ( ( ++$count % 1000 ) == 0 ) {
|
||||
print "$count history records processed.\n";
|
||||
|
|
@ -241,7 +241,7 @@ function convertOldTable()
|
|||
mysql_free_result( $oldres );
|
||||
|
||||
$sql = "UNLOCK TABLES";
|
||||
$newres = wfQuery( $sql );
|
||||
$newres = wfQuery( $sql, DB_WRITE );
|
||||
}
|
||||
|
||||
function convertImageDirectoriesX()
|
||||
|
|
@ -284,14 +284,14 @@ function convertImageDirectoriesX()
|
|||
|
||||
$sql = "DELETE FROM image WHERE img_name='" .
|
||||
addslashes( $nname ) . "'";
|
||||
$res = wfQuery( $sql );
|
||||
$res = wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$sql = "INSERT INTO image (img_name,img_timestamp,img_user," .
|
||||
"img_user_text,img_size,img_description) VALUES ('" .
|
||||
addslashes( $nname ) . "','" .
|
||||
date( "YmdHis" ) . "',0,'(Automated conversion)','" .
|
||||
filesize( "{$dest}/{$nname}" ) . "','')";
|
||||
$res = wfQuery( $sql );
|
||||
$res = wfQuery( $sql, DB_WRITE );
|
||||
} else {
|
||||
die( "Couldn't copy \"{$oname}\" to \"{$nname}\"\n" );
|
||||
}
|
||||
|
|
@ -306,7 +306,7 @@ function convertImageDirectories()
|
|||
|
||||
|
||||
$sql = "SELECT DISTINCT il_to FROM imagelinks";
|
||||
$result = wfQuery ( $sql ) ;
|
||||
$result = wfQuery ( $sql, DB_READ ) ;
|
||||
|
||||
while ( $row = mysql_fetch_object ( $result ) ) {
|
||||
$oname = $row->il_to ;
|
||||
|
|
@ -347,14 +347,14 @@ function convertImageDirectories()
|
|||
|
||||
$sql = "DELETE FROM image WHERE img_name='" .
|
||||
addslashes( $nname ) . "'";
|
||||
$res = wfQuery( $sql );
|
||||
$res = wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$sql = "INSERT INTO image (img_name,img_timestamp,img_user," .
|
||||
"img_user_text,img_size,img_description) VALUES ('" .
|
||||
addslashes( $nname ) . "','" .
|
||||
date( "YmdHis" ) . "',0,'(Automated conversion)','" .
|
||||
filesize( "{$dest}/{$nname}" ) . "','')";
|
||||
$res = wfQuery( $sql );
|
||||
$res = wfQuery( $sql, DB_WRITE );
|
||||
} else {
|
||||
echo( "Couldn't copy \"{$oname}\" to \"{$nname}\"\n" );
|
||||
}
|
||||
|
|
@ -557,36 +557,36 @@ function refillRandom()
|
|||
$sql = "INSERT INTO random(ra_current,ra_title) SELECT 0,cur_title " .
|
||||
"FROM cur WHERE cur_namespace=0 AND cur_is_redirect=0 " .
|
||||
"ORDER BY RAND() LIMIT 1000";
|
||||
wfQuery( $sql, $fname );
|
||||
wfQuery( $sql, DB_WRITE, $fname );
|
||||
|
||||
$sql = "UPDATE random SET ra_current=(ra_current+1)";
|
||||
wfQuery( $sql, $fname );
|
||||
wfQuery( $sql, DB_WRITE, $fname );
|
||||
|
||||
$sql = "DELETE FROM random WHERE ra_current>1";
|
||||
wfQuery( $sql, $fname );
|
||||
wfQuery( $sql, DB_WRITE, $fname );
|
||||
}
|
||||
|
||||
function renameOldTables()
|
||||
{
|
||||
$sql = "ALTER TABLE user RENAME TO old_user";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
$sql = "ALTER TABLE cur RENAME TO old_cur";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
$sql = "ALTER TABLE old RENAME TO old_old";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
$sql = "DROP TABLE IF EXISTS linked";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
$sql = "DROP TABLE IF EXISTS unlinked";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
}
|
||||
|
||||
function removeOldTables()
|
||||
{
|
||||
wfQuery( "DROP TABLE IF EXISTS old_user" );
|
||||
wfQuery( "DROP TABLE IF EXISTS old_linked" );
|
||||
wfQuery( "DROP TABLE IF EXISTS old_unlinked" );
|
||||
wfQuery( "DROP TABLE IF EXISTS old_cur" );
|
||||
wfQuery( "DROP TABLE IF EXISTS old_old" );
|
||||
wfQuery( "DROP TABLE IF EXISTS old_user", DB_WRITE );
|
||||
wfQuery( "DROP TABLE IF EXISTS old_linked", DB_WRITE );
|
||||
wfQuery( "DROP TABLE IF EXISTS old_unlinked", DB_WRITE );
|
||||
wfQuery( "DROP TABLE IF EXISTS old_cur", DB_WRITE );
|
||||
wfQuery( "DROP TABLE IF EXISTS old_old", DB_WRITE );
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -12,19 +12,19 @@ $wgDBuser = "wikiadmin";
|
|||
$wgDBpassword = $wgDBadminpassword;
|
||||
|
||||
$sql = "DROP TABLE IF EXISTS watchlist";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
$sql = "CREATE TABLE watchlist (
|
||||
wl_user int(5) unsigned NOT NULL,
|
||||
wl_page int(8) unsigned NOT NULL,
|
||||
UNIQUE KEY (wl_user, wl_page)
|
||||
) TYPE=MyISAM PACK_KEYS=1";
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
|
||||
$lc = new LinkCache;
|
||||
|
||||
# Now, convert!
|
||||
$sql = "SELECT user_id,user_watch FROM user";
|
||||
$res = wfQuery( $sql );
|
||||
$res = wfQuery( $sql, DB_READ );
|
||||
$nu = wfNumRows( $res );
|
||||
$sql = "INSERT into watchlist (wl_user,wl_page) VALUES ";
|
||||
$i = $n = 0;
|
||||
|
|
@ -40,7 +40,7 @@ while( $row = wfFetchObject( $res ) ) {
|
|||
}
|
||||
echo "$n users done.\n";
|
||||
if( $i ) {
|
||||
wfQuery( $sql );
|
||||
wfQuery( $sql, DB_WRITE );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -49,6 +49,6 @@ if( $i ) {
|
|||
$sql = "ALTER TABLE watchlist
|
||||
ADD INDEX wl_user (wl_user),
|
||||
ADD INDEX wl_page (wl_page)";
|
||||
#wfQuery( $sql );
|
||||
#wfQuery( $sql, DB_WRITE );
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ function texvc_cgi_renderMath( $tex )
|
|||
$md5_sql = mysql_escape_string(pack("H32", $md5));
|
||||
$sql = "SELECT math_outputhash,math_html_conservativeness,math_html,math_mathml FROM math WHERE math_inputhash = '".$md5_sql."'";
|
||||
|
||||
$res = wfQuery( $sql, $fname );
|
||||
$res = wfQuery( $sql, 0, $fname );
|
||||
if ( wfNumRows( $res ) == 0 )
|
||||
{
|
||||
$cmd = "./math/texvc ".escapeshellarg($wgTmpDirectory)." ".
|
||||
|
|
@ -112,7 +112,7 @@ function texvc_cgi_renderMath( $tex )
|
|||
|
||||
$sql = "INSERT INTO math VALUES ('".$md5_sql."', '".$outmd5_sql."', ".$conservativeness.", ".$sql_html.", ".$sql_mathml.")";
|
||||
|
||||
$res = wfQuery( $sql, $fname );
|
||||
$res = wfQuery( $sql, 0, $fname );
|
||||
// we don't really care if it fails
|
||||
} else {
|
||||
$rpage = wfFetchObject ( $res );
|
||||
|
|
|
|||
Loading…
Reference in a new issue