Use Doxygen @addtogroup instead of phpdoc @package && @subpackage
[lhc/web/wiklou.git] / maintenance / archives / upgradeWatchlist.php
1 <?php
2 /**
3 * @deprecated
4 * @addtogroup MaintenanceArchive
5 */
6
7 /** */
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.";
12 exit();
13
14 # Convert watchlists to new format
15
16 global $IP;
17 require_once( "../LocalSettings.php" );
18 require_once( "$IP/Setup.php" );
19
20 $wgTitle = Title::newFromText( "Rebuild links script" );
21 set_time_limit(0);
22
23 $wgDBuser = "wikiadmin";
24 $wgDBpassword = $wgDBadminpassword;
25
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 );
34
35 $lc = new LinkCache;
36
37 # Now, convert!
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 ";
42 $i = $n = 0;
43 while( $row = wfFetchObject( $res ) ) {
44 $list = explode( "\n", $row->user_watch );
45 $bits = array();
46 foreach( $list as $title ) {
47 if( $id = $lc->addLink( $title ) and ! $bits[$id]++) {
48 $sql .= ($i++ ? "," : "") . "({$row->user_id},{$id})";
49 }
50 }
51 if( ($n++ % 100) == 0 ) echo "$n of $nu users done...\n";
52 }
53 echo "$n users done.\n";
54 if( $i ) {
55 wfQuery( $sql, DB_MASTER );
56 }
57
58
59 # Add index
60 # is this necessary?
61 $sql = "ALTER TABLE watchlist
62 ADD INDEX wl_user (wl_user),
63 ADD INDEX wl_page (wl_page)";
64 #wfQuery( $sql, DB_MASTER );
65
66 ?>