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

rebuildRecentchanges.inc

Go to the documentation of this file.
00001 <?php 00002 00003 # Rebuild recent changes table. 00004 00005 function rebuildRecentChangesTable() 00006 { 00007 $sql = "DROP TABLE IF EXISTS recentchanges"; 00008 wfQuery( $sql ); 00009 00010 $sql = "CREATE TABLE recentchanges ( 00011 rc_timestamp varchar(14) binary NOT NULL default '', 00012 rc_cur_time varchar(14) binary NOT NULL default '', 00013 rc_user int(10) unsigned NOT NULL default '0', 00014 rc_user_text varchar(255) binary NOT NULL default '', 00015 rc_namespace tinyint(3) unsigned NOT NULL default '0', 00016 rc_title varchar(255) binary NOT NULL default '', 00017 rc_comment varchar(255) binary NOT NULL default '', 00018 rc_minor tinyint(3) unsigned NOT NULL default '0', 00019 rc_new tinyint(3) unsigned NOT NULL default '0', 00020 rc_cur_id int(10) unsigned NOT NULL default '0', 00021 rc_this_oldid int(10) unsigned NOT NULL default '0', 00022 rc_last_oldid int(10) unsigned NOT NULL default '0', 00023 INDEX rc_cur_id (rc_cur_id), 00024 INDEX rc_cur_time (rc_cur_time), 00025 INDEX rc_timestamp (rc_timestamp), 00026 INDEX rc_namespace (rc_namespace), 00027 INDEX rc_title (rc_title) 00028 ) TYPE=MyISAM PACK_KEYS=1;"; 00029 wfQuery( $sql ); 00030 00031 print( "Loading from CUR table...\n" ); 00032 00033 $sql = "INSERT INTO recentchanges (rc_timestamp,rc_cur_time,rc_user," . 00034 "rc_user_text,rc_namespace,rc_title,rc_comment,rc_minor,rc_new," . 00035 "rc_cur_id,rc_this_oldid,rc_last_oldid) SELECT cur_timestamp," . 00036 "cur_timestamp,cur_user,cur_user_text,cur_namespace,cur_title," . 00037 "cur_comment,cur_minor_edit,cur_is_new,cur_id,0,0 FROM cur " . 00038 "ORDER BY cur_timestamp DESC LIMIT 5000"; 00039 wfQuery( $sql ); 00040 00041 print( "Loading from OLD table...\n" ); 00042 00043 $sql = "INSERT INTO recentchanges (rc_timestamp,rc_cur_time,rc_user," . 00044 "rc_user_text,rc_namespace,rc_title,rc_comment,rc_minor,rc_new," . 00045 "rc_cur_id,rc_this_oldid,rc_last_oldid) SELECT old_timestamp,''," . 00046 "old_user,old_user_text,old_namespace,old_title,old_comment," . 00047 "old_minor_edit,0,0,old_id,0 FROM old ORDER BY old_timestamp " . 00048 "DESC LIMIT 5000"; 00049 wfQuery( $sql ); 00050 00051 $sql = "SELECT rc_timestamp FROM recentchanges " . 00052 "ORDER BY rc_timestamp DESC LIMIT 5000,1"; 00053 $res = wfQuery( $sql ); 00054 $obj = wfFetchObject( $res ); 00055 $ts = $obj->rc_timestamp; 00056 00057 $sql = "DELETE FROM recentchanges WHERE rc_timestamp < '{$ts}'"; 00058 wfQuery( $sql ); 00059 00060 rebuildRecentChangesTablePass2(); 00061 } 00062 00063 function rebuildRecentChangesTablePass2() 00064 { 00065 $ns = $id = $count = 0; 00066 $title = $ct = ""; 00067 00068 print( "Updating links...\n" ); 00069 00070 $sql = "SELECT rc_namespace,rc_title,rc_timestamp FROM recentchanges " . 00071 "ORDER BY rc_namespace,rc_title,rc_timestamp DESC"; 00072 $res = wfQuery( $sql ); 00073 00074 while ( $obj = wfFetchObject( $res ) ) { 00075 if ( ! ( $ns == $obj->rc_namespace && 00076 0 == strcmp( $title, wfStrencode( $obj->rc_title ) ) ) ) { 00077 00078 $ns = $obj->rc_namespace; 00079 $title = wfStrencode( $obj->rc_title ); 00080 00081 $sql = "SELECT cur_id,cur_timestamp FROM cur WHERE " . 00082 "cur_namespace={$ns} AND cur_title='{$title}'"; 00083 $res2 = wfQuery( $sql ); 00084 $obj2 = wfFetchObject( $res2 ); 00085 00086 $id = $obj2->cur_id; 00087 $ct = $obj2->cur_timestamp; 00088 } 00089 $sql = "SELECT old_id FROM old WHERE old_namespace={$ns} " . 00090 "AND old_title='{$title}' AND old_timestamp < '" . 00091 "{$obj->rc_timestamp}' ORDER BY old_timestamp DESC LIMIT 1"; 00092 $res2 = wfQuery( $sql ); 00093 00094 if ( 0 != wfNumRows( $res2 ) ) { 00095 $obj2 = wfFetchObject( $res2 ); 00096 00097 $sql = "UPDATE recentchanges SET rc_cur_id={$id},rc_cur_time=" . 00098 "'{$ct}',rc_last_oldid={$obj2->old_id} WHERE " . 00099 "rc_namespace={$ns} AND rc_title='{$title}' AND " . 00100 "rc_timestamp='{$obj->rc_timestamp}'"; 00101 wfQuery( $sql ); 00102 } else { 00103 $sql = "UPDATE recentchanges SET rc_cur_id={$id},rc_cur_time=" . 00104 "'{$ct}' WHERE rc_namespace={$ns} AND rc_title='{$title}' " . 00105 "AND rc_timestamp='{$obj->rc_timestamp}'"; 00106 wfQuery( $sql ); 00107 } 00108 00109 if ( 0 == ( ++$count % 500 ) ) { 00110 printf( "%d records processed.\n", $count ); 00111 } 00112 } 00113 } 00114 00115 00116 ?>

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