Index: trunk/phase3/maintenance/rebuildrecentchanges.inc |
— | — | @@ -64,16 +64,19 @@ |
65 | 65 | # Switch! Look up the previous last edit, if any |
66 | 66 | $lastCurId = intval( $obj->rc_cur_id ); |
67 | 67 | $emit = $obj->rc_timestamp; |
68 | | - $sql2 = "SELECT rev_id, rev_text_id FROM $revision " . |
| 68 | + $sql2 = "SELECT rev_id, rev_len, rev_text_id FROM $revision " . |
69 | 69 | "WHERE rev_page={$lastCurId} ". |
70 | 70 | "AND rev_timestamp<'{$emit}' ORDER BY rev_timestamp DESC LIMIT 1"; |
71 | 71 | $res2 = $dbw->query( $sql2 ); |
72 | 72 | if( $row = $dbw->fetchObject( $res2 ) ) { |
73 | 73 | $lastOldId = intval( $row->rev_id ); |
74 | 74 | $lastTextId = intval( $row->rev_text_id ); |
| 75 | + $lastSize = $row->rev_len; # Grab the last text size |
75 | 76 | } else { |
76 | 77 | # No previous edit |
77 | | - $lastOldId = $lastTextId = 0; |
| 78 | + $lastOldId = 0; |
| 79 | + $lastTextId = 0; |
| 80 | + $lastSize = NULL; |
78 | 81 | $new = 1; |
79 | 82 | } |
80 | 83 | $dbw->freeResult( $res2 ); |
— | — | @@ -81,18 +84,31 @@ |
82 | 85 | if( $lastCurId == 0 ) { |
83 | 86 | print "Uhhh, something wrong? No curid\n"; |
84 | 87 | } else { |
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 | + # Check the text if not in rev_len for the last entry's text size |
| 89 | + if( !$lastSize ) { |
| 90 | + $lastText = $dbw->selectField( 'text', 'old_text', array('old_id' => $lastTextId ) ); |
| 91 | + $lastSize = $lastText ? strlen($lastText) : 'NULL'; |
| 92 | + } |
88 | 93 | # 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'; |
| 94 | + $res3 = $dbw->select( 'revision', array('rev_len','rev_text_id'), array('rev_id' => $obj->rc_this_oldid ) ); |
| 95 | + if( $row = $dbw->fetchObject( $res3 ) ) { |
| 96 | + $textId = $row->rev_text_id; |
| 97 | + $size = $row->rev_len; |
| 98 | + } else { |
| 99 | + $textId = 0; |
| 100 | + $size = NULL; |
| 101 | + } |
| 102 | + # Check the text if not in rev_len for the entry's text size |
| 103 | + if( !$size ) { |
| 104 | + $text = $dbw->selectField( 'text', 'old_text', array('old_id' => $textId ) ); |
| 105 | + $size = $text ? strlen($text) : 'NULL'; |
| 106 | + } |
92 | 107 | |
93 | 108 | $sql3 = "UPDATE $recentchanges SET rc_last_oldid=$lastOldId,rc_new=$new,rc_type=$new," . |
94 | | - "rc_old_len=$lastSize,rc_new_len=$size " . |
| 109 | + "rc_old_len='$lastSize',rc_new_len='$size' " . |
95 | 110 | "WHERE rc_cur_id={$lastCurId} AND rc_this_oldid={$obj->rc_this_oldid}"; |
96 | 111 | $dbw->query( $sql3 ); |
| 112 | + |
97 | 113 | $lastOldId = intval( $obj->rc_this_oldid ); |
98 | 114 | } |
99 | 115 | } |