r72549 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72548‎ | r72549 | r72550 >
Date:20:30, 7 September 2010
Author:catrope
Status:deferred
Tags:
Comment:
ArticleAssessmentPilot: Minor fixes for action=articleassessment module
* Use $wgArticleAssessmentRatingCount instead of hardcoding 4
* Use false as the default value for $lastRating and $thisRating to distinguish it from 0, which is a legitimate rating value. Conveniently, it's still equivalent to 0 for the purposes of arithmetic
Modified paths:
  • /trunk/extensions/ArticleAssessmentPilot/api/ApiArticleAssessment.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleAssessmentPilot/api/ApiArticleAssessment.php
@@ -21,6 +21,9 @@
2222
2323 $dbr = wfGetDB( DB_SLAVE );
2424
 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
2528 // TODO:Refactor out...?
2629 $res = $dbr->select(
2730 'article_assessment',
@@ -36,7 +39,7 @@
3740 __METHOD__,
3841 array(
3942 'ORDER BY' => 'aa_revision DESC',
40 - 'LIMIT' => 4,
 43+ 'LIMIT' => $wgArticleAssessmentRatingCount,
4144 )
4245 );
4346
@@ -49,20 +52,19 @@
5053 $pageId = $params['pageid'];
5154 $revisionId = $params['revid'];
5255
53 - // TODO: Fold for loop into foreach above?
5456 foreach( $wgArticleAssessmentRatings as $rating ) {
55 - $lastRating = 0;
 57+ $lastRating = false;
5658 if ( isset( $lastRatings[$rating] ) ) {
5759 $lastRating = $lastRatings[$rating];
5860 }
5961
60 - $thisRating = 0;
 62+ $thisRating = false;
6163 if ( isset( $params["r{$rating}"] ) ) {
6264 $thisRating = $params["r{$rating}"];
6365 }
6466
6567 $this->insertPageRating( $pageId, $i, ( $thisRating - $lastRating ),
66 - ( $lastRating == 0 && $thisRating != 0 )
 68+ ( $lastRating === false && $thisRating !== false )
6769 );
6870
6971 $this->insertUserRatings( $pageId, $revisionId, $wgUser, $token, $rating, $thisRating );

Follow-up revisions

RevisionCommit summaryAuthorDate
r72559Followup r72549, $wgArticleAssessmentRatingCount doesn't exist, use count( $w...reedy22:31, 7 September 2010

Status & tagging log