Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

upgradeWatchlist.php

Go to the documentation of this file.
00001 <?php 00002 00003 print "This script is obsolete!"; 00004 print "It is retained in the source here in case some of its 00005 code might be useful for ad-hoc conversion tasks, but it is 00006 not maintained and probably won't even work as is."; 00007 exit(); 00008 00009 # Convert watchlists to new format 00010 00011 global $IP; 00012 require_once( "../LocalSettings.php" ); 00013 require_once( "$IP/Setup.php" ); 00014 00015 $wgTitle = Title::newFromText( "Rebuild links script" ); 00016 set_time_limit(0); 00017 00018 $wgDBuser = "wikiadmin"; 00019 $wgDBpassword = $wgDBadminpassword; 00020 00021 $sql = "DROP TABLE IF EXISTS watchlist"; 00022 wfQuery( $sql, DB_WRITE ); 00023 $sql = "CREATE TABLE watchlist ( 00024 wl_user int(5) unsigned NOT NULL, 00025 wl_page int(8) unsigned NOT NULL, 00026 UNIQUE KEY (wl_user, wl_page) 00027 ) TYPE=MyISAM PACK_KEYS=1"; 00028 wfQuery( $sql, DB_WRITE ); 00029 00030 $lc = new LinkCache; 00031 00032 # Now, convert! 00033 $sql = "SELECT user_id,user_watch FROM user"; 00034 $res = wfQuery( $sql, DB_READ ); 00035 $nu = wfNumRows( $res ); 00036 $sql = "INSERT into watchlist (wl_user,wl_page) VALUES "; 00037 $i = $n = 0; 00038 while( $row = wfFetchObject( $res ) ) { 00039 $list = explode( "\n", $row->user_watch ); 00040 $bits = array(); 00041 foreach( $list as $title ) { 00042 if( $id = $lc->addLink( $title ) and ! $bits[$id]++) { 00043 $sql .= ($i++ ? "," : "") . "({$row->user_id},{$id})"; 00044 } 00045 } 00046 if( ($n++ % 100) == 0 ) echo "$n of $nu users done...\n"; 00047 } 00048 echo "$n users done.\n"; 00049 if( $i ) { 00050 wfQuery( $sql, DB_WRITE ); 00051 } 00052 00053 00054 # Add index 00055 # is this necessary? 00056 $sql = "ALTER TABLE watchlist 00057 ADD INDEX wl_user (wl_user), 00058 ADD INDEX wl_page (wl_page)"; 00059 #wfQuery( $sql, DB_WRITE ); 00060 00061 ?>

Generated on Tue Jun 29 23:40:07 2004 for Mediawiki by doxygen 1.3.7