r84802 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84801‎ | r84802 | r84803 >
Date:16:01, 26 March 2011
Author:ashley
Status:deferred
Tags:
Comment:
my developer sense is tingling
Modified paths:
  • /trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php
@@ -58,7 +58,11 @@
5959 $res2 = $dbw->select(
6060 'user_stats',
6161 array( 'stats_user_id', 'stats_user_name' ),
62 - array( $stats->stats_fields[$this->categories[$row->gift_category]] . " >= {$row->gift_threshold}", 'stats_user_id<>0' ),
 62+ array(
 63+ $stats->stats_fields[$this->categories[$row->gift_category]] .
 64+ " >= {$row->gift_threshold}",
 65+ 'stats_user_id <> 0'
 66+ ),
6367 __METHOD__
6468 );
6569
@@ -151,11 +155,16 @@
152156
153157 public function doesGiftExistForThreshold( $category, $threshold ) {
154158 $dbr = wfGetDB( DB_SLAVE );
 159+ wfSuppressWarnings();
 160+ // Can cause notices like "Notice: Undefined index: user_image" after
 161+ // a user has uploaded their (first) avatar
 162+ $awardCategory = $this->categories[$category];
 163+ wfRestoreWarnings();
155164 $s = $dbr->selectRow(
156165 'system_gift',
157166 array( 'gift_id' ),
158167 array(
159 - 'gift_category' => $this->categories[$category],
 168+ 'gift_category' => $awardCategory,
160169 'gift_threshold' => $threshold
161170 ),
162171 __METHOD__
@@ -198,6 +207,8 @@
199208 * Gets the associated image for a system gift
200209 * @param $id Integer: system gift ID number
201210 * @param $size String: image size (s, m, ml or l)
 211+ * @return String: gift image filename (following the format
 212+ * sg_ID_SIZE.ext; for example, sg_1_l.jpg)
202213 */
203214 static function getGiftImage( $id, $size ) {
204215 global $wgUploadDirectory;
@@ -208,17 +219,25 @@
209220 } else {
210221 $img = 'default_' . $size . '.gif';
211222 }
 223+
212224 return $img . '?r=' . rand();
213225 }
214226
 227+ /**
 228+ * Get the list of all existing system gifts (awards).
 229+ *
 230+ * @param $limit Integer: LIMIT for the SQL query, 0 by default
 231+ * @param $page Integer: used to determine OFFSET for the SQL query;
 232+ * 0 by default
 233+ * @return Array: array containing gift info, including (but not limited
 234+ * to) gift ID, creation timestamp, name, description, etc.
 235+ */
215236 static function getGiftList( $limit = 0, $page = 0 ) {
216237 $dbr = wfGetDB( DB_SLAVE );
217238
218239 $limitvalue = 0;
219 - if ( $limit > 0 ) {
220 - if ( $page ) {
221 - $limitvalue = $page * $limit - ( $limit );
222 - }
 240+ if ( $limit > 0 && $page ) {
 241+ $limitvalue = $page * $limit - ( $limit );
223242 }
224243
225244 $res = $dbr->select(
@@ -261,6 +280,7 @@
262281 $s = $dbr->selectRow(
263282 'system_gift',
264283 array( 'COUNT(*) AS count' ),
 284+ array(),
265285 __METHOD__
266286 );
267287 if ( $s !== false ) {

Status & tagging log