r102180 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102179‎ | r102180 | r102181 >
Date:15:11, 6 November 2011
Author:ashley
Status:deferred
Tags:socialprofile 
Comment:
SocialProfile: as per Markus' in-depth review:
*remove unused class member variables
*mark Gifts' and UserGifts' constructors as public
*optimize the DB queries in Gifts::getCustomCreatedGiftCount() and Gifts::getGiftCount()
*use WebRequest instead of $_POST
*var -> public/private
Modified paths:
  • /trunk/extensions/SocialProfile/UserGifts/GiftsClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiftManager.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/UserGiftsClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserGifts/UserGiftsClass.php
@@ -5,22 +5,13 @@
66 */
77 class UserGifts {
88
9 - /**
10 - * All member variables should be considered private
11 - * Please use the accessor functions
12 - */
 9+ private $user_id; # Text form (spaces not underscores) of the main part
 10+ private $user_name; # Text form (spaces not underscores) of the main part
1311
14 - /**#@+
15 - * @private
16 - */
17 - var $user_id; # Text form (spaces not underscores) of the main part
18 - var $user_name; # Text form (spaces not underscores) of the main part
19 -
2012 /**
2113 * Constructor
22 - * @private
2314 */
24 - /* private */ function __construct( $username ) {
 15+ public function __construct( $username ) {
2516 $title1 = Title::newFromDBkey( $username );
2617 $this->user_name = $title1->getText();
2718 $this->user_id = User::idFromName( $this->user_name );
Index: trunk/extensions/SocialProfile/UserGifts/GiftsClass.php
@@ -7,24 +7,10 @@
88 class Gifts {
99
1010 /**
11 - * All member variables should be considered private
12 - * Please use the accessor functions
13 - */
14 -
15 - /**#@+
16 - * @private
17 - */
18 - var $user_id; # Text form (spaces not underscores) of the main part
19 - var $user_name; # Text form (spaces not underscores) of the main part
20 -
21 - /**
2211 * Constructor
23 - * @private
2412 */
25 - /* private */ function __construct() {
 13+ public function __construct() {}
2614
27 - }
28 -
2915 /**
3016 * Adds a gift to the database
3117 * @param $gift_name Mixed: name of the gift, as supplied by the user
@@ -203,7 +189,7 @@
204190 $gift_count = 0;
205191 $s = $dbr->selectRow(
206192 'gift',
207 - array( 'COUNT(*) AS count' ),
 193+ array( 'COUNT(gift_id) AS count' ),
208194 array( 'gift_creator_user_id' => $user_id ),
209195 __METHOD__
210196 );
@@ -218,7 +204,7 @@
219205 $gift_count = 0;
220206 $s = $dbr->selectRow(
221207 'gift',
222 - array( 'COUNT(*) AS count' ),
 208+ array( 'COUNT(gift_id) AS count' ),
223209 array( 'gift_given_count' => $gift_count ),
224210 __METHOD__
225211 );
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManager.php
@@ -34,12 +34,12 @@
3535 // Add CSS
3636 $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' );
3737
38 - if ( count( $_POST ) ) {
39 - if ( !( $_POST['id'] ) ) {
 38+ if ( $wgRequest->wasPosted() ) {
 39+ if ( !$wgRequest->getInt( 'id' ) ) {
4040 $giftId = Gifts::addGift(
41 - $_POST['gift_name'],
42 - $_POST['gift_description'],
43 - intval( $_POST['access'] )
 41+ $wgRequest->getVal( 'gift_name' ),
 42+ $wgRequest->getVal( 'gift_description' ),
 43+ $wgRequest->getInt( 'access' )
4444 );
4545 $wgOut->addHTML(
4646 '<span class="view-status">' .
@@ -47,12 +47,12 @@
4848 '</span><br /><br />'
4949 );
5050 } else {
51 - $giftId = intval( $_POST['id'] );
 51+ $giftId = $wgRequest->getInt( 'id' );
5252 Gifts::updateGift(
5353 $giftId,
54 - $_POST['gift_name'],
55 - $_POST['gift_description'],
56 - intval( $_POST['access'] )
 54+ $wgRequest->getVal( 'gift_name' ),
 55+ $wgRequest->getVal( 'gift_description' ),
 56+ $wgRequest->getInt( 'access' )
5757 );
5858 $wgOut->addHTML(
5959 '<span class="view-status">' .
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php
@@ -9,13 +9,13 @@
1010 */
1111 class GiftManagerLogo extends UnlistedSpecialPage {
1212
13 - var $mUploadFile, $mUploadDescription, $mIgnoreWarning;
14 - var $mUploadSaveName, $mUploadTempName, $mUploadSize, $mUploadOldVersion;
15 - var $mUploadCopyStatus, $mUploadSource, $mReUpload, $mAction, $mUpload;
16 - var $mOname, $mSessionKey, $mStashed, $mDestFile;
17 - var $avatarUploadDirectory;
18 - var $fileExtensions;
19 - var $gift_id;
 13+ public $mUploadFile, $mUploadDescription, $mIgnoreWarning;
 14+ public $mUploadSaveName, $mUploadTempName, $mUploadSize, $mUploadOldVersion;
 15+ public $mUploadCopyStatus, $mUploadSource, $mReUpload, $mAction, $mUpload;
 16+ public $mOname, $mSessionKey, $mStashed, $mDestFile;
 17+ public $avatarUploadDirectory;
 18+ public $fileExtensions;
 19+ public $gift_id;
2020
2121 /**
2222 * Constructor

Follow-up revisions

RevisionCommit summaryAuthorDate
r104105SocialProfile: partial revert of r102176, r102180 and r102288 -- UserProfile'...ashley23:39, 23 November 2011

Status & tagging log