X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2Frebuildrecentchanges.inc;h=888588fa57f6e1ce05aac98dc05d8432b40a0b9f;hb=739cab780c0fd0265da048f709688eca0b0edd72;hp=2d9fc2f0727814456623b6cb99069268c8264a2b;hpb=6bbcf091bf4513df95db2783097d90e2a13ceec9;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/rebuildrecentchanges.inc b/maintenance/rebuildrecentchanges.inc index 2d9fc2f072..888588fa57 100644 --- a/maintenance/rebuildrecentchanges.inc +++ b/maintenance/rebuildrecentchanges.inc @@ -17,7 +17,7 @@ function rebuildRecentChangesTablePass1() $dbw->delete( 'recentchanges', '*' ); print( "Loading from CUR table...\n" ); - + $dbw->insertSelect( 'recentchanges', 'cur', array( 'rc_timestamp' => 'cur_timestamp', @@ -33,29 +33,31 @@ function rebuildRecentChangesTablePass1() 'rc_cur_id' => 'cur_id', 'rc_this_oldid' => 0, 'rc_last_oldid' => 0, - 'rc_type' => 'IF(cur_is_new,' . RC_NEW . ',' . RC_EDIT . ')' - ), '*', $fname, array( 'ORDER BY' => 'inverse_timestamp', 'LIMIT' => 5000 ) + 'rc_type' => $dbw->conditional( 'cur_is_new != 0', RC_NEW, RC_EDIT ), + ), '*', $fname, array( 'ORDER BY' => 'cur_timestamp DESC', 'LIMIT' => 5000 ) ); print( "Loading from OLD table...\n" ); $sql = "INSERT INTO $recentchanges (rc_timestamp,rc_cur_time,rc_user," . "rc_user_text,rc_namespace,rc_title,rc_comment,rc_minor,rc_bot,rc_new," . - "rc_cur_id,rc_this_oldid,rc_last_oldid) SELECT old_timestamp,cur_timestamp," . + "rc_cur_id,rc_this_oldid,rc_last_oldid,rc_type) SELECT old_timestamp,cur_timestamp," . "old_user,old_user_text,old_namespace,old_title,old_comment," . - "old_minor_edit,0,0,cur_id,old_id,0 FROM $old,$cur " . - "WHERE old_namespace=cur_namespace AND old_title=cur_title ORDER BY $old.inverse_timestamp " . + "old_minor_edit,0,0,cur_id,old_id,0,0 FROM $old,$cur " . + "WHERE old_namespace=cur_namespace AND old_title=cur_title ORDER BY old_timestamp DESC " . "LIMIT 5000"; $dbw->query( $sql ); $sql = "SELECT rc_timestamp FROM $recentchanges " . - "ORDER BY rc_timestamp DESC LIMIT 5000,1"; + "ORDER BY rc_timestamp DESC" . $dbw->limitResult( 1, 5000 ); $res = $dbw->query( $sql ); $obj = $dbw->fetchObject( $res ); - $ts = $obj->rc_timestamp; - - $sql = "DELETE FROM $recentchanges WHERE rc_timestamp < '{$ts}'"; - $dbw->query( $sql ); + if( $obj ) { + $ts = $obj->rc_timestamp; + + $sql = "DELETE FROM $recentchanges WHERE rc_timestamp < '{$ts}'"; + $dbw->query( $sql ); + } } function rebuildRecentChangesTablePass2() @@ -81,10 +83,10 @@ function rebuildRecentChangesTablePass2() if( $obj->rc_cur_id != $lastCurId ) { # Switch! Look up the previous last edit, if any $lastCurId = IntVal( $obj->rc_cur_id ); - $emit = wfInvertTimestamp( $obj->rc_timestamp ); + $emit = $obj->rc_timestamp; $sql2 = "SELECT old_id FROM $old,$cur " . "WHERE old_namespace=cur_namespace AND old_title=cur_title AND cur_id={$lastCurId} ". - "AND $old.inverse_timestamp>'{$emit}' ORDER BY $old.inverse_timestamp LIMIT 1"; + "AND old_timestamp<'{$emit}' ORDER BY old_timestamp DESC LIMIT 1"; $res2 = $dbw->query( $sql2 ); if( $row = $dbw->fetchObject( $res2 ) ) { $lastOldId = IntVal( $row->old_id );