Add .php5 entry for mwScriptLoader.
[lhc/web/wiklou.git] / maintenance / archives / upgradeWatchlist.php
1 <?php
2 /**
3 * @file
4 * @deprecated
5 * @ingroup MaintenanceArchive
6 */
7
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(1);
14
15 # Convert watchlists to new format
16
17 global $IP;
18 require_once( "../LocalSettings.php" );
19 require_once( "$IP/Setup.php" );
20
21 $wgTitle = Title::newFromText( "Rebuild links script" );
22 set_time_limit(0);
23
24 $wgDBuser = "wikiadmin";
25 $wgDBpassword = $wgDBadminpassword;
26
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 ) ENGINE=MyISAM PACK_KEYS=1";
34 wfQuery( $sql, DB_MASTER );
35
36 $lc = new LinkCache;
37
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})";
50 }
51 }
52 if( ($n++ % 100) == 0 ) echo "$n of $nu users done...\n";
53 }
54 echo "$n users done.\n";
55 if( $i ) {
56 wfQuery( $sql, DB_MASTER );
57 }
58
59
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 );
66
67