r22785 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22784‎ | r22785 | r22786 >
Date:03:57, 6 June 2007
Author:aaron
Status:old
Tags:
Comment:
*Fill in rc_old_len and rc_new_len (bug 9542)
Modified paths:
  • /trunk/phase3/maintenance/rebuildrecentchanges.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/rebuildrecentchanges.inc
@@ -49,10 +49,9 @@
5050 $dbw = wfGetDB( DB_MASTER );
5151 list ($recentchanges, $revision) = $dbw->tableNamesN( 'recentchanges', 'revision' );
5252
53 - print( "Updating links...\n" );
 53+ print( "Updating links and size differences...\n" );
5454
5555 # Fill in the rc_last_oldid field, which points to the previous edit
56 - #
5756 $sql = "SELECT rc_cur_id,rc_this_oldid,rc_timestamp FROM $recentchanges " .
5857 "ORDER BY rc_cur_id,rc_timestamp";
5958 $res = $dbw->query( $sql, DB_MASTER );
@@ -65,15 +64,16 @@
6665 # Switch! Look up the previous last edit, if any
6766 $lastCurId = intval( $obj->rc_cur_id );
6867 $emit = $obj->rc_timestamp;
69 - $sql2 = "SELECT rev_id FROM $revision " .
 68+ $sql2 = "SELECT rev_id, rev_text_id FROM $revision " .
7069 "WHERE rev_page={$lastCurId} ".
7170 "AND rev_timestamp<'{$emit}' ORDER BY rev_timestamp DESC LIMIT 1";
7271 $res2 = $dbw->query( $sql2 );
7372 if( $row = $dbw->fetchObject( $res2 ) ) {
7473 $lastOldId = intval( $row->rev_id );
 74+ $lastTextId = intval( $row->rev_text_id );
7575 } else {
7676 # No previous edit
77 - $lastOldId = 0;
 77+ $lastOldId = $lastTextId = 0;
7878 $new = 1;
7979 }
8080 $dbw->freeResult( $res2 );
@@ -81,7 +81,16 @@
8282 if( $lastCurId == 0 ) {
8383 print "Uhhh, something wrong? No curid\n";
8484 } else {
85 - $sql3 = "UPDATE $recentchanges SET rc_last_oldid=$lastOldId,rc_new=$new,rc_type=$new " .
 85+ # Grab the last edit's text size
 86+ $lastText = $dbw->selectField( 'text', 'old_text', array('old_id' => $lastTextId ) );
 87+ $lastSize = $lastText ? strlen($lastText) : 'NULL';
 88+ # Grab the entry's text size
 89+ $textId = $dbw->selectField( 'revision', 'rev_text_id', array('rev_id' => $obj->rc_this_oldid ) );
 90+ $text = $dbw->selectField( 'text', 'old_text', array('old_id' => $textId ) );
 91+ $size = $text ? strlen($text) : 'NULL';
 92+
 93+ $sql3 = "UPDATE $recentchanges SET rc_last_oldid=$lastOldId,rc_new=$new,rc_type=$new," .
 94+ "rc_old_len=$lastSize,rc_new_len=$size " .
8695 "WHERE rc_cur_id={$lastCurId} AND rc_this_oldid={$obj->rc_this_oldid}";
8796 $dbw->query( $sql3 );
8897 $lastOldId = intval( $obj->rc_this_oldid );

Follow-up revisions

RevisionCommit summaryAuthorDate
r22791Merged revisions 22747-22790 via svnmerge from...david09:21, 6 June 2007

Status & tagging log