* Use double quoted consistently on attributes in linker output; preparing for new...
[mediawiki.git] / maintenance / archives / upgradeWatchlist.php
blobb4605a5007de368c7e297c5ccc2a77557c9fc65d
1 <?php
2 /**
3 * @deprecated
4 * @package MediaWiki
5 * @subpackage MaintenanceArchive
6 */
8 /** */
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.";
13 exit();
15 # Convert watchlists to new format
17 global $IP;
18 require_once( "../LocalSettings.php" );
19 require_once( "$IP/Setup.php" );
21 $wgTitle = Title::newFromText( "Rebuild links script" );
22 set_time_limit(0);
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 );
36 $lc = new LinkCache;
38 # Now, convert!
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 ";
43 $i = $n = 0;
44 while( $row = wfFetchObject( $res ) ) {
45 $list = explode( "\n", $row->user_watch );
46 $bits = array();
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";
55 if( $i ) {
56 wfQuery( $sql, DB_MASTER );
60 # Add index
61 # is this necessary?
62 $sql = "ALTER TABLE watchlist
63 ADD INDEX wl_user (wl_user),
64 ADD INDEX wl_page (wl_page)";
65 #wfQuery( $sql, DB_MASTER );