Index: trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php |
— | — | @@ -85,14 +85,22 @@ |
86 | 86 | private function insertPageRating( $pageId, $ratingId, $updateAddition, $thisRating, $lastRating ) { |
87 | 87 | $dbw = wfGetDB( DB_MASTER ); |
88 | 88 | |
89 | | - $newRating = ( $lastRating === false && $thisRating !== false ); |
| 89 | + // 0 == No change in rating count |
| 90 | + // 1 == No rating last time (or new rating), and now there is |
| 91 | + // -1 == Rating last time, but abstained this time |
90 | 92 | $countChange = 0; |
91 | | - if ( $newRating ) { |
92 | | - $countChange = 1; // Garunteed new rating |
93 | | - } else if ( $lastRating === 0 && $thisRating !== 0 ) { |
94 | | - $countChange = 1; // "New" rating as last was 0 (abstained) |
95 | | - } else if ( $lastRating !== 0 && $thisRating === 0 ) { |
96 | | - $countChange = -1; // Rating abstained this time, but there was a prior rating |
| 93 | + if ( $lastRating === false || $lastRating === 0 ) { |
| 94 | + if ( $newRating === 0 ) { |
| 95 | + $countChange = 0; |
| 96 | + } else { |
| 97 | + $countChange = 1; |
| 98 | + } |
| 99 | + } else { // Last rating was > 0 |
| 100 | + if ( $newRating === 0 ) { |
| 101 | + $countChange = -1; |
| 102 | + } else { |
| 103 | + $countChange = 0; |
| 104 | + } |
97 | 105 | } |
98 | 106 | |
99 | 107 | $dbw->insert( |