r85579 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85578‎ | r85579 | r85580 >
Date:21:32, 6 April 2011
Author:tparscal
Status:ok
Tags:
Comment:
Added more casting (should be all of it now) and added countall to output that has userrating. Also fixed bug in SQL query where rating id was sorted before revision, causing invalid userrating information to be used.
Modified paths:
  • /trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php
@@ -48,7 +48,7 @@
4949 'total' => (int) $row->aap_total,
5050 'count' => (int) $row->aap_count,
5151 'countall' => isset( $historicCounts[$row->aap_rating_id] )
52 - ? $historicCounts[$row->aap_rating_id] : 0
 52+ ? (int) $historicCounts[$row->aap_rating_id] : 0
5353 );
5454 }
5555
@@ -68,7 +68,7 @@
6969 if ( isset( $userRatings[$rating['ratingid']] ) ) {
7070 // Rating value
7171 $ratings[$params['pageid']]['ratings'][$i]['userrating'] =
72 - $userRatings[$rating['ratingid']]['value'];
 72+ (int) $userRatings[$rating['ratingid']]['value'];
7373 // Expiration
7474 if ( $userRatings[$rating['ratingid']]['revision'] < $revisionLimit ) {
7575 $ratings[$params['pageid']]['status'] = 'expired';
@@ -83,7 +83,7 @@
8484 foreach ( $userRatings as $ratingId => $userRating ) {
8585 // Revision
8686 if ( !isset( $ratings[$params['pageid']]['revid'] ) ) {
87 - $ratings[$params['pageid']]['revid'] = $userRating['revision'];
 87+ $ratings[$params['pageid']]['revid'] = (int) $userRating['revision'];
8888 }
8989 // Ratings
9090 if ( !isset( $ratings[$params['pageid']]['ratings'] ) ) {
@@ -95,7 +95,9 @@
9696 'ratingdesc' => $userRating['text'],
9797 'total' => 0,
9898 'count' => 0,
99 - 'userrating' => $userRating['value'],
 99+ 'countall' => isset( $historicCounts[$row->aap_rating_id] )
 100+ ? (int) $historicCounts[$row->aap_rating_id] : 0,
 101+ 'userrating' => (int) $userRating['value'],
100102 );
101103 }
102104 }
@@ -184,7 +186,7 @@
185187 __METHOD__,
186188 array(
187189 'LIMIT' => count( $wgArticleFeedbackRatings ),
188 - 'ORDER BY' => array( 'aa_rating_id', 'aa_revision DESC' ),
 190+ 'ORDER BY' => array( 'aa_revision DESC', 'aa_rating_id' ),
189191 ),
190192 array(
191193 'article_feedback_ratings' => array( 'LEFT JOIN', array( 'aar_id=aa_rating_id' ) )

Status & tagging log