00001 <?php 00009 print "This script is obsolete!"; 00010 print "It is retained in the source here in case some of its 00011 code might be useful for ad-hoc conversion tasks, but it is 00012 not maintained and probably won't even work as is."; 00013 exit(); 00014 00015 # Convert watchlists to new format 00016 00017 global $IP; 00018 require_once( "../LocalSettings.php" ); 00019 require_once( "$IP/Setup.php" ); 00020 00021 $wgTitle = Title::newFromText( "Rebuild links script" ); 00022 set_time_limit(0); 00023 00024 $wgDBuser = "wikiadmin"; 00025 $wgDBpassword = $wgDBadminpassword; 00026 00027 $sql = "DROP TABLE IF EXISTS watchlist"; 00028 wfQuery( $sql, DB_MASTER ); 00029 $sql = "CREATE TABLE watchlist ( 00030 wl_user int(5) unsigned NOT NULL, 00031 wl_page int(8) unsigned NOT NULL, 00032 UNIQUE KEY (wl_user, wl_page) 00033 ) ENGINE=MyISAM PACK_KEYS=1"; 00034 wfQuery( $sql, DB_MASTER ); 00035 00036 $lc = new LinkCache; 00037 00038 # Now, convert! 00039 $sql = "SELECT user_id,user_watch FROM user"; 00040 $res = wfQuery( $sql, DB_SLAVE ); 00041 $nu = wfNumRows( $res ); 00042 $sql = "INSERT into watchlist (wl_user,wl_page) VALUES "; 00043 $i = $n = 0; 00044 while( $row = wfFetchObject( $res ) ) { 00045 $list = explode( "\n", $row->user_watch ); 00046 $bits = array(); 00047 foreach( $list as $title ) { 00048 if( $id = $lc->addLink( $title ) and ! $bits[$id]++) { 00049 $sql .= ($i++ ? "," : "") . "({$row->user_id},{$id})"; 00050 } 00051 } 00052 if( ($n++ % 100) == 0 ) echo "$n of $nu users done...\n"; 00053 } 00054 echo "$n users done.\n"; 00055 if( $i ) { 00056 wfQuery( $sql, DB_MASTER ); 00057 } 00058 00059 00060 # Add index 00061 # is this necessary? 00062 $sql = "ALTER TABLE watchlist 00063 ADD INDEX wl_user (wl_user), 00064 ADD INDEX wl_page (wl_page)"; 00065 #wfQuery( $sql, DB_MASTER ); 00066 00067