Index: trunk/phase3/maintenance/rebuildrecentchanges.inc |
— | — | @@ -49,10 +49,9 @@ |
50 | 50 | $dbw = wfGetDB( DB_MASTER ); |
51 | 51 | list ($recentchanges, $revision) = $dbw->tableNamesN( 'recentchanges', 'revision' ); |
52 | 52 | |
53 | | - print( "Updating links...\n" ); |
| 53 | + print( "Updating links and size differences...\n" ); |
54 | 54 | |
55 | 55 | # Fill in the rc_last_oldid field, which points to the previous edit |
56 | | - # |
57 | 56 | $sql = "SELECT rc_cur_id,rc_this_oldid,rc_timestamp FROM $recentchanges " . |
58 | 57 | "ORDER BY rc_cur_id,rc_timestamp"; |
59 | 58 | $res = $dbw->query( $sql, DB_MASTER ); |
— | — | @@ -65,15 +64,16 @@ |
66 | 65 | # Switch! Look up the previous last edit, if any |
67 | 66 | $lastCurId = intval( $obj->rc_cur_id ); |
68 | 67 | $emit = $obj->rc_timestamp; |
69 | | - $sql2 = "SELECT rev_id FROM $revision " . |
| 68 | + $sql2 = "SELECT rev_id, rev_text_id FROM $revision " . |
70 | 69 | "WHERE rev_page={$lastCurId} ". |
71 | 70 | "AND rev_timestamp<'{$emit}' ORDER BY rev_timestamp DESC LIMIT 1"; |
72 | 71 | $res2 = $dbw->query( $sql2 ); |
73 | 72 | if( $row = $dbw->fetchObject( $res2 ) ) { |
74 | 73 | $lastOldId = intval( $row->rev_id ); |
| 74 | + $lastTextId = intval( $row->rev_text_id ); |
75 | 75 | } else { |
76 | 76 | # No previous edit |
77 | | - $lastOldId = 0; |
| 77 | + $lastOldId = $lastTextId = 0; |
78 | 78 | $new = 1; |
79 | 79 | } |
80 | 80 | $dbw->freeResult( $res2 ); |
— | — | @@ -81,7 +81,16 @@ |
82 | 82 | if( $lastCurId == 0 ) { |
83 | 83 | print "Uhhh, something wrong? No curid\n"; |
84 | 84 | } 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 " . |
86 | 95 | "WHERE rc_cur_id={$lastCurId} AND rc_this_oldid={$obj->rc_this_oldid}"; |
87 | 96 | $dbw->query( $sql3 ); |
88 | 97 | $lastOldId = intval( $obj->rc_this_oldid ); |