r97094 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97093‎ | r97094 | r97095 >
Date:20:23, 14 September 2011
Author:ialex
Status:ok
Tags:
Comment:
Use local context instead of global variables
Modified paths:
  • /trunk/phase3/includes/specials/SpecialChangeEmail.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialChangeEmail.php
@@ -35,35 +35,34 @@
3636 * Main execution point
3737 */
3838 function execute( $par ) {
39 - global $wgRequest;
40 -
41 - $out = $this->getOutput();
4239 if ( wfReadOnly() ) {
43 - $out->readOnlyPage();
44 - return;
 40+ throw new ReadOnlyError;
4541 }
4642
47 - $user = $this->getUser();
 43+ $request = $this->getRequest();
 44+ $this->mPassword = $request->getVal( 'wpPassword' );
 45+ $this->mNewEmail = $request->getVal( 'wpNewEmail' );
4846
49 - $this->mPassword = $wgRequest->getVal( 'wpPassword' );
50 - $this->mNewEmail = $wgRequest->getVal( 'wpNewEmail' );
51 -
5247 $this->setHeaders();
5348 $this->outputHeader();
 49+
 50+ $out = $this->getOutput();
5451 $out->disallowUserJs();
5552
56 - if ( !$wgRequest->wasPosted() && !$user->isLoggedIn() ) {
 53+ $user = $this->getUser();
 54+
 55+ if ( !$request->wasPosted() && !$user->isLoggedIn() ) {
5756 $this->error( wfMsg( 'changeemail-no-info' ) );
5857 return;
5958 }
6059
61 - if ( $wgRequest->wasPosted() && $wgRequest->getBool( 'wpCancel' ) ) {
 60+ if ( $request->wasPosted() && $request->getBool( 'wpCancel' ) ) {
6261 $this->doReturnTo();
6362 return;
6463 }
6564
66 - if ( $wgRequest->wasPosted()
67 - && $user->matchEditToken( $wgRequest->getVal( 'token' ) ) )
 65+ if ( $request->wasPosted()
 66+ && $user->matchEditToken( $request->getVal( 'token' ) ) )
6867 {
6968 $info = $this->attemptChange( $user, $this->mPassword, $this->mNewEmail );
7069 if ( $info === true ) {
@@ -81,8 +80,7 @@
8281 }
8382
8483 protected function doReturnTo( $type = 'hard' ) {
85 - global $wgRequest;
86 - $titleObj = Title::newFromText( $wgRequest->getVal( 'returnto' ) );
 84+ $titleObj = Title::newFromText( $this->getRequest()->getVal( 'returnto' ) );
8785 if ( !$titleObj instanceof Title ) {
8886 $titleObj = Title::newMainPage();
8987 }
@@ -98,8 +96,6 @@
9997 }
10098
10199 protected function showForm() {
102 - global $wgRequest;
103 -
104100 $user = $this->getUser();
105101
106102 $oldEmailText = $user->getEmail()
@@ -114,7 +110,7 @@
115111 'action' => $this->getTitle()->getLocalUrl(),
116112 'id' => 'mw-changeemail-form' ) ) . "\n" .
117113 Html::hidden( 'token', $user->editToken() ) . "\n" .
118 - Html::hidden( 'returnto', $wgRequest->getVal( 'returnto' ) ) . "\n" .
 114+ Html::hidden( 'returnto', $this->getRequest()->getVal( 'returnto' ) ) . "\n" .
119115 wfMsgExt( 'changeemail-text', array( 'parse' ) ) . "\n" .
120116 Xml::openElement( 'table', array( 'id' => 'mw-changeemail-table' ) ) . "\n" .
121117 $this->pretty( array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r97173Merged revisions 97087,97091-97092,97094,97096-97098,97100-97101,97103,97136,...dantman16:19, 15 September 2011

Status & tagging log