rc_timestamp; $sql = "DELETE FROM recentchanges WHERE rc_timestamp < '{$ts}'"; wfQuery( $sql ); rebuildRecentChangesTablePass2(); } function rebuildRecentChangesTablePass2() { $ns = $id = $count = 0; $title = $ct = ""; print( "Updating links...\n" ); $sql = "SELECT rc_namespace,rc_title,rc_timestamp FROM recentchanges " . "ORDER BY rc_namespace,rc_title,rc_timestamp DESC"; $res = wfQuery( $sql ); while ( $obj = wfFetchObject( $res ) ) { if ( ! ( $ns == $obj->rc_namespace && 0 == strcmp( $title, wfStrencode( $obj->rc_title ) ) ) ) { $ns = $obj->rc_namespace; $title = wfStrencode( $obj->rc_title ); $sql = "SELECT cur_id,cur_timestamp FROM cur WHERE " . "cur_namespace={$ns} AND cur_title='{$title}'"; $res2 = wfQuery( $sql ); $obj2 = wfFetchObject( $res2 ); $id = $obj2->cur_id; $ct = $obj2->cur_timestamp; } $sql = "SELECT old_id FROM old WHERE old_namespace={$ns} " . "AND old_title='{$title}' AND old_timestamp < '" . "{$obj->rc_timestamp}' ORDER BY old_timestamp DESC LIMIT 1"; $res2 = wfQuery( $sql ); if ( 0 != wfNumRows( $res2 ) ) { $obj2 = wfFetchObject( $res2 ); $sql = "UPDATE recentchanges SET rc_cur_id={$id},rc_cur_time=" . "'{$ct}',rc_last_oldid={$obj2->old_id} WHERE " . "rc_namespace={$ns} AND rc_title='{$title}' AND " . "rc_timestamp='{$obj->rc_timestamp}'"; wfQuery( $sql ); } else { $sql = "UPDATE recentchanges SET rc_cur_id={$id},rc_cur_time=" . "'{$ct}' WHERE rc_namespace={$ns} AND rc_title='{$title}' " . "AND rc_timestamp='{$obj->rc_timestamp}'"; wfQuery( $sql ); } if ( 0 == ( ++$count % 500 ) ) { printf( "%d records processed.\n", $count ); } } } ?>