r98642 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98641‎ | r98642 | r98643 >
Date:23:22, 1 October 2011
Author:aaron
Status:deferred
Tags:
Comment:
Pass in IP to AccountRequestSubmission to avoid $wgRequest use
Modified paths:
  • /trunk/extensions/ConfirmAccount/business/AccountRequestSubmission.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/presentation/specialpages/actions/RequestAccount_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmAccount/business/AccountRequestSubmission.php
@@ -14,6 +14,7 @@
1515 protected $type;
1616 protected $areas;
1717 protected $registration;
 18+ protected $ip;
1819 /* File attachment fields */
1920 protected $attachmentSrcName; // user given attachment base name
2021 protected $attachmentPrevName; // user given attachment base name last attempt
@@ -23,21 +24,22 @@
2425
2526 public function __construct( User $requester, array $params ) {
2627 $this->requester = $requester;
27 - $this->userName = $params['userName'];
28 - $this->realName = $params['realName'];
 28+ $this->userName = trim( $params['userName'] );
 29+ $this->realName = trim( $params['realName'] );
2930 $this->tosAccepted = $params['tosAccepted'];
3031 $this->email = $params['email'];
31 - $this->bio = $params['bio'];
32 - $this->notes = $params['notes'];
33 - $this->urls = $params['urls'];
 32+ $this->bio = trim( $params['bio'] );
 33+ $this->notes = trim( $params['notes'] );
 34+ $this->urls = trim( $params['urls'] );
3435 $this->type = $params['type'];
3536 $this->areas = $params['areas'];
 37+ $this->ip = $params['ip'];
 38+ $this->registration = wfTimestamp( TS_MW, $params['registration'] );
3639 $this->attachmentPrevName = $params['attachmentPrevName'];
3740 $this->attachmentSrcName = $params['attachmentSrcName'];
3841 $this->attachmentDidNotForget = $params['attachmentDidNotForget'];
3942 $this->attachmentSize = $params['attachmentSize'];
4043 $this->attachmentTempPath = $params['attachmentTempPath'];
41 - $this->registration = wfTimestamp( TS_MW, $params['registration'] );
4244 }
4345
4446 public function getAttachmentDidNotForget() {
@@ -61,8 +63,7 @@
6264 $reqUser = $this->requester;
6365
6466 # Now create a dummy user ($u) and check if it is valid
65 - $name = trim( $this->userName );
66 - if ( $name === '' ) {
 67+ if ( $this->userName === '' ) {
6768 return array( 'accountreq_no_name', wfMsgHtml( 'noname' ) );
6869 }
6970 $u = User::newFromName( $name, 'creatable' );
@@ -71,7 +72,7 @@
7273 }
7374 # No request spamming...
7475 if ( $wgAccountRequestThrottle && $reqUser->isPingLimitable() ) {
75 - $key = wfMemcKey( 'acctrequest', 'ip', wfGetIP() );
 76+ $key = wfMemcKey( 'acctrequest', 'ip', $this->ip );
7677 $value = (int)$wgMemc->get( $key );
7778 if ( $value > $wgAccountRequestThrottle ) {
7879 return array( 'accountreq_throttled',
@@ -165,8 +166,6 @@
166167 $expires = null; // passed by reference
167168 $token = ConfirmAccount::getConfirmationToken( $u, $expires );
168169
169 - global $wgRequest;
170 - $ip = $wgRequest->getIP();
171170 # Insert into pending requests...
172171 $req = UserAccountRequest::newFromArray( array(
173172 'name' => $u->getName(),
@@ -185,7 +184,7 @@
186185 'comment' => '',
187186 'email_token' => md5( $token ),
188187 'email_token_expires' => $expires,
189 - 'ip' => $ip,
 188+ 'ip' => $this->ip,
190189 ) );
191190 $dbw->begin();
192191 $req->insertOn();
Index: trunk/extensions/ConfirmAccount/presentation/specialpages/actions/RequestAccount_body.php
@@ -273,6 +273,7 @@
274274 'type' => $this->mType,
275275 'areas' => $this->mAreaSet,
276276 'registration' => wfTimestampNow(),
 277+ 'ip' => $this->getRequest()->getIP(),
277278 'attachmentPrevName' => $this->mPrevAttachment,
278279 'attachmentSrcName' => $this->mSrcName,
279280 'attachmentDidNotForget' => $this->mForgotAttachment, // confusing name :)

Status & tagging log