5 * @subpackage MaintenanceArchive
9 print "This script is obsolete!";
10 print "It is retained in the source here in case some of its
11 code might be useful for ad-hoc conversion tasks, but it is
12 not maintained and probably won't even work as is.";
15 # Convert watchlists to new format
18 require_once( "../LocalSettings.php" );
19 require_once( "$IP/Setup.php" );
21 $wgTitle = Title
::newFromText( "Rebuild links script" );
24 $wgDBuser = "wikiadmin";
25 $wgDBpassword = $wgDBadminpassword;
27 $sql = "DROP TABLE IF EXISTS watchlist";
28 wfQuery( $sql, DB_MASTER
);
29 $sql = "CREATE TABLE watchlist (
30 wl_user int(5) unsigned NOT NULL,
31 wl_page int(8) unsigned NOT NULL,
32 UNIQUE KEY (wl_user, wl_page)
33 ) TYPE=MyISAM PACK_KEYS=1";
34 wfQuery( $sql, DB_MASTER
);
39 $sql = "SELECT user_id,user_watch FROM user";
40 $res = wfQuery( $sql, DB_SLAVE
);
41 $nu = wfNumRows( $res );
42 $sql = "INSERT into watchlist (wl_user,wl_page) VALUES ";
44 while( $row = wfFetchObject( $res ) ) {
45 $list = explode( "\n", $row->user_watch
);
47 foreach( $list as $title ) {
48 if( $id = $lc->addLink( $title ) and ! $bits[$id]++
) {
49 $sql .= ($i++ ?
"," : "") . "({$row->user_id},{$id})";
52 if( ($n++ %
100) == 0 ) echo "$n of $nu users done...\n";
54 echo "$n users done.\n";
56 wfQuery( $sql, DB_MASTER
);
62 $sql = "ALTER TABLE watchlist
63 ADD INDEX wl_user (wl_user),
64 ADD INDEX wl_page (wl_page)";
65 #wfQuery( $sql, DB_MASTER );