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