Index: trunk/extensions/ArticleAssessmentPilot/api/ApiArticleAssessment.php |
— | — | @@ -21,6 +21,9 @@ |
22 | 22 | |
23 | 23 | $dbr = wfGetDB( DB_SLAVE ); |
24 | 24 | |
| 25 | + // Query the latest ratings by this user for this page, |
| 26 | + // possibly for an older revision |
| 27 | + // TODO: Make this query saner once $wgArticleAssessmentRatingCount has been redone |
25 | 28 | // TODO:Refactor out...? |
26 | 29 | $res = $dbr->select( |
27 | 30 | 'article_assessment', |
— | — | @@ -36,7 +39,7 @@ |
37 | 40 | __METHOD__, |
38 | 41 | array( |
39 | 42 | 'ORDER BY' => 'aa_revision DESC', |
40 | | - 'LIMIT' => 4, |
| 43 | + 'LIMIT' => $wgArticleAssessmentRatingCount, |
41 | 44 | ) |
42 | 45 | ); |
43 | 46 | |
— | — | @@ -49,20 +52,19 @@ |
50 | 53 | $pageId = $params['pageid']; |
51 | 54 | $revisionId = $params['revid']; |
52 | 55 | |
53 | | - // TODO: Fold for loop into foreach above? |
54 | 56 | foreach( $wgArticleAssessmentRatings as $rating ) { |
55 | | - $lastRating = 0; |
| 57 | + $lastRating = false; |
56 | 58 | if ( isset( $lastRatings[$rating] ) ) { |
57 | 59 | $lastRating = $lastRatings[$rating]; |
58 | 60 | } |
59 | 61 | |
60 | | - $thisRating = 0; |
| 62 | + $thisRating = false; |
61 | 63 | if ( isset( $params["r{$rating}"] ) ) { |
62 | 64 | $thisRating = $params["r{$rating}"]; |
63 | 65 | } |
64 | 66 | |
65 | 67 | $this->insertPageRating( $pageId, $i, ( $thisRating - $lastRating ), |
66 | | - ( $lastRating == 0 && $thisRating != 0 ) |
| 68 | + ( $lastRating === false && $thisRating !== false ) |
67 | 69 | ); |
68 | 70 | |
69 | 71 | $this->insertUserRatings( $pageId, $revisionId, $wgUser, $token, $rating, $thisRating ); |