Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/api/ApiArticleFeedback.php |
— | — | @@ -164,6 +164,13 @@ |
165 | 165 | */ |
166 | 166 | private function insertRevisionRating( $pageId, $revisionId, $lastRevision, $ratingId, $updateAddition, $thisRating, $lastRating ) { |
167 | 167 | $dbw = wfGetDB( DB_MASTER ); |
| 168 | + |
| 169 | + // Fix previous logic bug: if the revision IDs of the previous and current ratings are NOT the same, |
| 170 | + // set $lastRating to zero. Otherwise we will try to adjust instead of add, which may result in negative |
| 171 | + // values and wrap-arounds and all that sort of nastiness. |
| 172 | + if ( $revisionId != $lastRevision ) { |
| 173 | + $lastRating = 0; |
| 174 | + } |
168 | 175 | |
169 | 176 | // Try to insert a new "totals" row for this page,rev,rating set |
170 | 177 | $dbw->insert( |
— | — | @@ -182,7 +189,8 @@ |
183 | 190 | // If that succeded in inserting a row, then we are for sure rating a previously unrated |
184 | 191 | // revision, and we need to add more information about this rating to the new "totals" row, |
185 | 192 | // as well as remove the previous rating values from the previous "totals" row |
186 | | - if ( $dbw->affectedRows() ) { |
| 193 | + // HACK: This behavior is stupid, don't do this |
| 194 | + if ( $dbw->affectedRows() && false ) { |
187 | 195 | // If there was a previous rating, there should be a "totals" row for it's revision |
188 | 196 | if ( $lastRating ) { |
189 | 197 | // Deduct the previous rating values from the previous "totals" row |