Skip to content

Instantly share code, notes, and snippets.

@catrope
Created September 10, 2011 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catrope/1208442 to your computer and use it in GitHub Desktop.
Save catrope/1208442 to your computer and use it in GitHub Desktop.
Attempted fix for AFT counter drift bug
Index: api/ApiArticleFeedback.php
===================================================================
--- api/ApiArticleFeedback.php (revision 96655)
+++ api/ApiArticleFeedback.php (working copy)
@@ -164,6 +164,13 @@
*/
private function insertRevisionRating( $pageId, $revisionId, $lastRevision, $ratingId, $updateAddition, $thisRating, $lastRating ) {
$dbw = wfGetDB( DB_MASTER );
+
+ // Fix previous logic bug: if the revision IDs of the previous and current ratings are NOT the same,
+ // set $lastRating to zero. Otherwise we will try to adjust instead of add, which may result in negative
+ // values and wrap-arounds and all that sort of nastiness.
+ if ( $revisionId != $lastRevision ) {
+ $lastRating = 0;
+ }
// Try to insert a new "totals" row for this page,rev,rating set
$dbw->insert(
@@ -182,7 +189,8 @@
// If that succeded in inserting a row, then we are for sure rating a previously unrated
// revision, and we need to add more information about this rating to the new "totals" row,
// as well as remove the previous rating values from the previous "totals" row
- if ( $dbw->affectedRows() ) {
+ // HACK: This behavior is stupid, don't do this
+ if ( $dbw->affectedRows() && false ) {
// If there was a previous rating, there should be a "totals" row for it's revision
if ( $lastRating ) {
// Deduct the previous rating values from the previous "totals" row
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment