r92525 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92524‎ | r92525 | r92526 >
Date:11:37, 19 July 2011
Author:ashley
Status:ok
Tags:
Comment:
SocialProfile: fix bug #27981 - update award counters whenever an award is given out (either created or the user reaches the specified threshold of a pre-existing award)
Modified paths:
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/UserSystemGiftsClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php
@@ -89,7 +89,11 @@
9090 $output .= '<div class="cleared"></div>
9191 </div>';
9292
93 - $output .= '<div class="ga-recent">
 93+ // If someone else in addition to the current user has gotten this
 94+ // award, then and only then show the "Other recipients of this
 95+ // award" header and the list of avatars
 96+ if ( $gift['gift_count'] > 1 ) {
 97+ $output .= '<div class="ga-recent">
9498 <div class="ga-recent-title">' .
9599 wfMsg( 'ga-recent-recipients-award' ) .
96100 '</div>
@@ -101,19 +105,21 @@
102106 ) .
103107 '</div>';
104108
105 - foreach ( $res as $row ) {
106 - $userToId = $row->sg_user_id;
107 - $avatar = new wAvatar( $userToId, 'ml' );
108 - $userNameLink = Title::makeTitle( NS_USER, $row->sg_user_name );
 109+ foreach ( $res as $row ) {
 110+ $userToId = $row->sg_user_id;
 111+ $avatar = new wAvatar( $userToId, 'ml' );
 112+ $userNameLink = Title::makeTitle( NS_USER, $row->sg_user_name );
109113
110 - $output .= '<a href="' . $userNameLink->escapeFullURL() . "\">
 114+ $output .= '<a href="' . $userNameLink->escapeFullURL() . "\">
111115 {$avatar->getAvatarURL()}
112116 </a>";
 117+ }
 118+
 119+ $output .= '<div class="cleared"></div>
 120+ </div>'; // .ga-recent
113121 }
114122
115 - $output .= '<div class="cleared"></div>
116 - </div>
117 - </div>';
 123+ $output .= '</div>';
118124
119125 $wgOut->addHTML( $output );
120126 } else {
Index: trunk/extensions/SocialProfile/SystemGifts/UserSystemGiftsClass.php
@@ -384,13 +384,14 @@
385385 * Update the counter that tracks how many times a system gift has been
386386 * given out.
387387 *
388 - * @param $gift_id Integer: ID number of the system gift that we're tracking
 388+ * @param $giftId Integer: ID number of the system gift that we're tracking
389389 */
390 - private function incGiftGivenCount( $gift_id ) {
 390+ public static function incGiftGivenCount( $giftId ) {
391391 $dbw = wfGetDB( DB_MASTER );
392 - $dbw->update( 'system_gift',
393 - array( 'gift_given_count=gift_given_count+1' ),
394 - array( 'gift_id' => $gift_id ),
 392+ $dbw->update(
 393+ 'system_gift',
 394+ array( 'gift_given_count = gift_given_count + 1' ),
 395+ array( 'gift_id' => $giftId ),
395396 __METHOD__
396397 );
397398 }
Index: trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php
@@ -52,7 +52,7 @@
5353 array( 'ORDER BY' => 'gift_category, gift_threshold ASC' )
5454 );
5555
56 - $x = 1;
 56+ $x = 0;
5757 foreach ( $res as $row ) {
5858 if ( $row->gift_category ) {
5959 $res2 = $dbw->select(
@@ -83,6 +83,9 @@
8484 $sg_key = wfMemcKey( 'user', 'profile', 'system_gifts', "{$row2->stats_user_id}" );
8585 $wgMemc->delete( $sg_key );
8686
 87+ // Update counters (bug #27981)
 88+ UserSystemGifts::incGiftGivenCount( $row->gift_id );
 89+
8790 $wgOut->addHTML( $row2->stats_user_name . ' got ' . $row->gift_name . '<br />' );
8891 $x++;
8992 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r92527SocialProfile: follow-up to r92525: static method call so that PHP doesn't ha...ashley11:52, 19 July 2011

Status & tagging log