X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Frebuildrecentchanges.inc;h=e077da52214ed488f9988564d6f89828fd92904d;hb=8d66c4d82b00dc84eddd51beecb62499253979c0;hp=f4d739e66e1c112fcbd311651d2edd26255ac1e4;hpb=ac549401d4ddaf655ec47cd1e66092fdc83ab30b;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/rebuildrecentchanges.inc b/maintenance/rebuildrecentchanges.inc index f4d739e66e..e077da5221 100644 --- a/maintenance/rebuildrecentchanges.inc +++ b/maintenance/rebuildrecentchanges.inc @@ -1,62 +1,54 @@ tableNames( 'recentchanges', 'cur', 'old' ); + extract( $dbw->tableNames( 'recentchanges', 'cur', 'old' ) ); $dbw->delete( 'recentchanges', '*' ); - print( "Loading from CUR table...\n" ); + print( "Loading from page and revision tables...\n" ); - $dbw->insertSelect( 'recentchanges', 'cur', + global $wgRCMaxAge; + $cutoff = time() - $wgRCMaxAge; + $dbw->insertSelect( 'recentchanges', array( 'page', 'revision' ), array( - 'rc_timestamp' => 'cur_timestamp', - 'rc_cur_time' => 'cur_timestamp', - 'rc_user' => 'cur_user', - 'rc_user_text' => 'cur_user_text', - 'rc_namespace' => 'cur_namespace', - 'rc_title' => 'cur_title', - 'rc_comment' => 'cur_comment', - 'rc_minor' => 'cur_minor_edit', - 'rc_bot' => 0, - 'rc_new' => 'cur_is_new', - '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_timestamp' => 'rev_timestamp', + 'rc_cur_time' => 'rev_timestamp', + 'rc_user' => 'rev_user', + 'rc_user_text' => 'rev_user_text', + 'rc_namespace' => 'page_namespace', + 'rc_title' => 'page_title', + 'rc_comment' => 'rev_comment', + 'rc_minor' => 'rev_minor_edit', + 'rc_bot' => 0, + 'rc_new' => 'page_is_new', + 'rc_cur_id' => 'page_id', + 'rc_this_oldid' => 'rev_id', + 'rc_last_oldid' => 0, // is this ok? + 'rc_type' => $dbw->conditional( 'page_is_new != 0', RC_NEW, RC_EDIT ), + ), array( + 'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $cutoff ) ), + 'rev_page=page_id' + ), $fname, + array(), // INSERT options + array( 'ORDER BY' => 'rev_timestamp', 'LIMIT' => 5000 ) // SELECT options ); - - 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," . - "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 " . - "LIMIT 5000"; - $dbw->query( $sql ); - - $sql = "SELECT rc_timestamp FROM $recentchanges " . - "ORDER BY rc_timestamp DESC LIMIT 5000,1"; - $res = $dbw->query( $sql ); - $obj = $dbw->fetchObject( $res ); - $ts = $obj->rc_timestamp; - - $sql = "DELETE FROM $recentchanges WHERE rc_timestamp < '{$ts}'"; - $dbw->query( $sql ); } function rebuildRecentChangesTablePass2() { $dbw =& wfGetDB( DB_MASTER ); - extract( $dbw->tableNames( 'recentchanges', 'cur', 'old' ); + extract( $dbw->tableNames( 'recentchanges', 'revision' ) ); $ns = $id = $count = 0; $title = $ct = ""; @@ -75,14 +67,14 @@ function rebuildRecentChangesTablePass2() $new = 0; 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 ); - $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"; + $lastCurId = intval( $obj->rc_cur_id ); + $emit = $obj->rc_timestamp; + $sql2 = "SELECT rev_id FROM $revision " . + "WHERE rev_page={$lastCurId} ". + "AND rev_timestamp<'{$emit}' ORDER BY rev_timestamp DESC LIMIT 1"; $res2 = $dbw->query( $sql2 ); if( $row = $dbw->fetchObject( $res2 ) ) { - $lastOldId = IntVal( $row->old_id ); + $lastOldId = intval( $row->rev_id ); } else { # No previous edit $lastOldId = 0; @@ -96,7 +88,7 @@ function rebuildRecentChangesTablePass2() $sql3 = "UPDATE $recentchanges SET rc_last_oldid=$lastOldId,rc_new=$new,rc_type=$new " . "WHERE rc_cur_id={$lastCurId} AND rc_this_oldid={$obj->rc_this_oldid}"; $dbw->query( $sql3 ); - $lastOldId = IntVal( $obj->rc_this_oldid ); + $lastOldId = intval( $obj->rc_this_oldid ); } } $dbw->freeResult( $res );