# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# http://www.gnu.org/copyleft/gpl.html
+/**
+ * @todo document
+ * @deprecated
+ * @package MediaWiki
+ * @subpackage Maintenance
+ */
+
+/** */
+die( "This import script is not currently maintained.
+If you need it you'll have to modify it as necessary.\n");
+
if ( ! is_readable( "../LocalSettings.php" ) ) {
print "A copy of your installation's LocalSettings.php\n" .
"must exist in the source directory.\n";
ini_set("implicit_flush", 1);
$DP = "../includes";
-include_once( "../LocalSettings.php" );
-include_once( "../AdminSettings.php" );
+require_once( "../LocalSettings.php" );
+require_once( "../AdminSettings.php" );
$wgDBuser = $wgDBadminuser;
$wgDBpassword = $wgDBadminpassword;
$sep = ( DIRECTORY_SEPARATOR == "\\" ) ? ";" : ":";
ini_set( "include_path", "$IP$sep$include_path" );
-include_once( "Setup.php" );
+require_once( "Setup.php" );
-include_once( "../install-utils.inc" );
-include_once( "InitialiseMessages.inc" );
-include_once( "rebuildlinks.inc" );
-include_once( "rebuildrecentchanges.inc" );
-include_once( "rebuildtextindex.inc" );
+require_once( "../install-utils.inc" );
+require_once( "InitialiseMessages.inc" );
+require_once( "rebuildlinks.inc" );
+require_once( "rebuildrecentchanges.inc" );
+require_once( "rebuildtextindex.inc" );
+/**
+ * @todo document
+ * @package MediaWiki
+ * @subpackage Maintenance
+ */
class Phase2Importer {
var $olddb, $titleCache;
# MySQL copies everything over to the new database and tweaks a few things.
function importCurData() {
print "Clearing pages from default install, if any...\n";
- wfQuery( "DELETE FROM cur", DB_WRITE );
+ wfQuery( "DELETE FROM cur", DB_MASTER );
print "Importing current revision data...\n";
wfQuery( "INSERT INTO cur (cur_id,cur_namespace,cur_title,cur_text,cur_comment,
cur_user,cur_user_text,cur_timestamp,cur_restrictions,cur_counter,
- cur_is_redirect,cur_minor_edit,cur_is_new,cur_random,cur_touched,inverse_timestamp)
+ cur_is_redirect,cur_minor_edit,cur_is_new,cur_random,cur_touched)
SELECT cur_id,0,cur_title,cur_text,cur_comment,
cur_user,cur_user_text,cur_timestamp,REPLACE(cur_restrictions,'is_',''),cur_counter,
- cur_text like '#redirect%',cur_minor_edit,0,RAND(),NOW()+0,99999999999999-cur_timestamp
- FROM {$this->olddb}.cur", DB_WRITE );
+ cur_text like '#redirect%',cur_minor_edit,0,RAND(),NOW()+0,
+ FROM {$this->olddb}.cur", DB_MASTER );
$n = mysql_affected_rows();
print "$n rows imported.\n";
}
function importOldData() {
print "Clearing old revision data from default install, if any...\n";
- wfQuery( "DELETE FROM old", DB_WRITE );
+ wfQuery( "DELETE FROM old", DB_MASTER );
print "Importing old revision data...\n";
wfQuery( "INSERT INTO old (old_id,old_namespace,old_title,old_text,old_comment,
- old_user,old_user_text,old_timestamp,old_minor_edit,old_flags,inverse_timestamp)
+ old_user,old_user_text,old_timestamp,old_minor_edit,old_flags)
SELECT old_id,0,old_title,old_text,old_comment,
- old_user,old_user_text,old_timestamp,old_minor_edit,'',99999999999999-old_timestamp
- FROM {$this->olddb}.old", DB_WRITE );
+ old_user,old_user_text,old_timestamp,old_minor_edit,''
+ FROM {$this->olddb}.old", DB_MASTER );
$n = mysql_affected_rows();
print "$n rows imported.\n";
}
function importUserData() {
print "Clearing users from default install, if any...\n";
- wfQuery( "DELETE FROM user", DB_WRITE );
+ wfQuery( "DELETE FROM user", DB_MASTER );
print "Importing user data...\n";
wfQuery( "INSERT INTO $newdb.user (user_id,user_name,user_rights,
user_password,user_newpassword,user_email,user_options,user_touched)
SELECT user_id,user_name,REPLACE(user_rights,'is_',''),
MD5(CONCAT(user_id,'-',MD5(user_password))),'',user_email,user_options,NOW()+0
- FROM {$this->olddb}.user", DB_WRITE );
+ FROM {$this->olddb}.user", DB_MASTER );
$n = mysql_affected_rows();
print "$n rows imported.\n";
}
# A little less clean...
function importWatchlists() {
print "Clearing watchlists from default install, if any...\n";
- wfQuery( "DELETE FROM watchlist", DB_WRITE );
+ wfQuery( "DELETE FROM watchlist", DB_MASTER );
print "Importing watchlists...";
- $res = wfQuery( "SELECT user_id,user_watch FROM {$this->olddb}.user WHERE user_watch != ''", DB_WRITE );
+ $res = wfQuery( "SELECT user_id,user_watch FROM {$this->olddb}.user WHERE user_watch != ''", DB_MASTER );
$total = wfNumRows( $res );
$n = 0;
print " ($total total)\n";
} else {
$ns = $title->getNamespace();
$t = wfStrencode( $title->getDBkey() );
- wfQuery( "INSERT INTO watchlist(wl_user,wl_namespace,wl_title) VALUES ($id,$ns,'$t')", DB_WRITE );
+ wfQuery( "INSERT INTO watchlist(wl_user,wl_namespace,wl_title) VALUES ($id,$ns,'$t')", DB_MASTER );
}
}
if( ++$n % 50 == 0 ) {
function importLinkData() {
# MUST BE CALLED BEFORE! fixCurTitles()
print "Clearing links from default install, if any...\n";
- wfQuery( "DELETE FROM links", DB_WRITE );
- wfQuery( "DELETE FROM brokenlinks", DB_WRITE );
+ wfQuery( "DELETE FROM links", DB_MASTER );
+ wfQuery( "DELETE FROM brokenlinks", DB_MASTER );
print "Importing live links...";
wfQuery( "INSERT INTO links (l_from, l_to)
SELECT DISTINCT linked_from,cur_id
FROM {$this->olddb}.linked,{$this->olddb}.cur
- WHERE linked_to=cur_title", DB_WRITE );
+ WHERE linked_to=cur_title", DB_MASTER );
$n = mysql_affected_rows();
print "$n rows imported.\n";
wfQuery( "INSERT INTO brokenlinks (bl_from, bl_to)
SELECT DISTINCT cur_id,unlinked_to
FROM {$this->olddb}.unlinked,{$this->olddb}.cur
- WHERE unlinked_from=cur_title", DB_WRITE );
+ WHERE unlinked_from=cur_title", DB_MASTER );
$n = mysql_affected_rows();
print "$n rows imported.\n";
}
function fixTitles( $table ) {
print "Fixing titles in $table...";
- $res = wfQuery( "SELECT DISTINCT {$table}_title AS title FROM $table", DB_WRITE );
+ $res = wfQuery( "SELECT DISTINCT {$table}_title AS title FROM $table", DB_MASTER );
$total = wfNumRows( $res );
$n = 0;
print " ($total total)\n";
$ns = $title->getNamespace();
$t = wfStrencode( $title->getDBkey() );
wfQuery( "UPDATE $table SET {$table}_namespace=$ns,{$table}_title='$t'
- WHERE {$table}_namespace=0 AND {$table}_title='$xt'", DB_WRITE );
+ WHERE {$table}_namespace=0 AND {$table}_title='$xt'", DB_MASTER );
}
if( ++$n % 50 == 0 ) {
print "$n\n";
if ( "yes" == $s || "on" == $s ) { $nops["hover"] = 1; }
$c = $ops["cols"];
- if ( $c < 20 || c > 200 ) { $nops["cols"] = 80; }
+ if ( $c < 20 || $c > 200 ) { $nops["cols"] = 80; }
else { $nops["cols"] = $c; }
$r = $ops["rows"];
if ( $r < 5 || $r > 100 ) { $nops["rows"] = 20; }
function fixUserOptions() {
print "Fixing user options...";
- $res = wfQuery( "SELECT user_id,user_options FROM user", DB_WRITE );
+ $res = wfQuery( "SELECT user_id,user_options FROM user", DB_MASTER );
$total = wfNumRows( $res );
$n = 0;
print " ($total total)\n";
while( $row = wfFetchObject( $res ) ) {
$id = IntVal( $row->user_id );
$option = wfStrencode( $this->rewriteUserOptions( $row->user_options ) );
- wfQuery( "UPDATE user SET user_options='$option' WHERE user_id=$id LIMIT 1", DB_WRITE );
+ wfQuery( "UPDATE user SET user_options='$option' WHERE user_id=$id LIMIT 1", DB_MASTER );
if( ++$n % 50 == 0 ) {
print "$n\n";
}
}
+/**
+ * @todo document
+ * @package MediaWiki
+ * @subpackage Maintenance
+ */
class TitleCache {
var $hash = array();
$importer = new Phase2Importer( $olddb );
$importer->importAll();
-?>
\ No newline at end of file
+?>