From 30d8b44756414a910241767b2097c91945259645 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 6 Jun 2007 03:57:14 +0000 Subject: [PATCH] *Fill in rc_old_len and rc_new_len (bug 9542) --- maintenance/rebuildrecentchanges.inc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/maintenance/rebuildrecentchanges.inc b/maintenance/rebuildrecentchanges.inc index 2cad0fea58..03cffa159a 100644 --- a/maintenance/rebuildrecentchanges.inc +++ b/maintenance/rebuildrecentchanges.inc @@ -49,10 +49,9 @@ function rebuildRecentChangesTablePass2() $dbw = wfGetDB( DB_MASTER ); list ($recentchanges, $revision) = $dbw->tableNamesN( 'recentchanges', 'revision' ); - print( "Updating links...\n" ); + print( "Updating links and size differences...\n" ); # Fill in the rc_last_oldid field, which points to the previous edit - # $sql = "SELECT rc_cur_id,rc_this_oldid,rc_timestamp FROM $recentchanges " . "ORDER BY rc_cur_id,rc_timestamp"; $res = $dbw->query( $sql, DB_MASTER ); @@ -65,15 +64,16 @@ function rebuildRecentChangesTablePass2() # Switch! Look up the previous last edit, if any $lastCurId = intval( $obj->rc_cur_id ); $emit = $obj->rc_timestamp; - $sql2 = "SELECT rev_id FROM $revision " . + $sql2 = "SELECT rev_id, rev_text_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->rev_id ); + $lastTextId = intval( $row->rev_text_id ); } else { # No previous edit - $lastOldId = 0; + $lastOldId = $lastTextId = 0; $new = 1; } $dbw->freeResult( $res2 ); @@ -81,7 +81,16 @@ function rebuildRecentChangesTablePass2() if( $lastCurId == 0 ) { print "Uhhh, something wrong? No curid\n"; } else { - $sql3 = "UPDATE $recentchanges SET rc_last_oldid=$lastOldId,rc_new=$new,rc_type=$new " . + # Grab the last edit's text size + $lastText = $dbw->selectField( 'text', 'old_text', array('old_id' => $lastTextId ) ); + $lastSize = $lastText ? strlen($lastText) : 'NULL'; + # Grab the entry's text size + $textId = $dbw->selectField( 'revision', 'rev_text_id', array('rev_id' => $obj->rc_this_oldid ) ); + $text = $dbw->selectField( 'text', 'old_text', array('old_id' => $textId ) ); + $size = $text ? strlen($text) : 'NULL'; + + $sql3 = "UPDATE $recentchanges SET rc_last_oldid=$lastOldId,rc_new=$new,rc_type=$new," . + "rc_old_len=$lastSize,rc_new_len=$size " . "WHERE rc_cur_id={$lastCurId} AND rc_this_oldid={$obj->rc_this_oldid}"; $dbw->query( $sql3 ); $lastOldId = intval( $obj->rc_this_oldid ); -- 2.20.1