Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / specials / SpecialPasswordReset.php
index 292b575..c3ed91f 100644 (file)
@@ -51,6 +51,10 @@ class SpecialPasswordReset extends FormSpecialPage {
                parent::__construct( 'PasswordReset', 'editmyprivateinfo' );
        }
 
+       public function doesWrites() {
+               return true;
+       }
+
        public function userCanExecute( User $user ) {
                return $this->canChangePassword( $user ) === true && parent::userCanExecute( $user );
        }
@@ -69,12 +73,12 @@ class SpecialPasswordReset extends FormSpecialPage {
        protected function getFormFields() {
                global $wgAuth;
                $resetRoutes = $this->getConfig()->get( 'PasswordResetRoutes' );
-               $a = array();
+               $a = [];
                if ( isset( $resetRoutes['username'] ) && $resetRoutes['username'] ) {
-                       $a['Username'] = array(
+                       $a['Username'] = [
                                'type' => 'text',
                                'label-message' => 'passwordreset-username',
-                       );
+                       ];
 
                        if ( $this->getUser()->isLoggedIn() ) {
                                $a['Username']['default'] = $this->getUser()->getName();
@@ -82,27 +86,27 @@ class SpecialPasswordReset extends FormSpecialPage {
                }
 
                if ( isset( $resetRoutes['email'] ) && $resetRoutes['email'] ) {
-                       $a['Email'] = array(
+                       $a['Email'] = [
                                'type' => 'email',
                                'label-message' => 'passwordreset-email',
-                       );
+                       ];
                }
 
                if ( isset( $resetRoutes['domain'] ) && $resetRoutes['domain'] ) {
                        $domains = $wgAuth->domainList();
-                       $a['Domain'] = array(
+                       $a['Domain'] = [
                                'type' => 'select',
                                'options' => $domains,
                                'label-message' => 'passwordreset-domain',
-                       );
+                       ];
                }
 
                if ( $this->getUser()->isAllowed( 'passwordreset' ) ) {
-                       $a['Capture'] = array(
+                       $a['Capture'] = [
                                'type' => 'check',
                                'label-message' => 'passwordreset-capture',
                                'help-message' => 'passwordreset-capture-help',
-                       );
+                       ];
                }
 
                return $a;
@@ -167,7 +171,7 @@ class SpecialPasswordReset extends FormSpecialPage {
 
                if ( isset( $data['Username'] ) && $data['Username'] !== '' ) {
                        $method = 'username';
-                       $users = array( User::newFromName( $data['Username'] ) );
+                       $users = [ User::newFromName( $data['Username'] ) ];
                } elseif ( isset( $data['Email'] )
                        && $data['Email'] !== ''
                        && Sanitizer::validateEmail( $data['Email'] )
@@ -176,12 +180,12 @@ class SpecialPasswordReset extends FormSpecialPage {
                        $res = wfGetDB( DB_SLAVE )->select(
                                'user',
                                User::selectFields(),
-                               array( 'user_email' => $data['Email'] ),
+                               [ 'user_email' => $data['Email'] ],
                                __METHOD__
                        );
 
                        if ( $res ) {
-                               $users = array();
+                               $users = [];
 
                                foreach ( $res as $row ) {
                                        $users[] = User::newFromRow( $row );
@@ -196,9 +200,9 @@ class SpecialPasswordReset extends FormSpecialPage {
                }
 
                // Check for hooks (captcha etc), and allow them to modify the users list
-               $error = array();
-               if ( !Hooks::run( 'SpecialPasswordResetOnSubmit', array( &$users, $data, &$error ) ) ) {
-                       return array( $error );
+               $error = [];
+               if ( !Hooks::run( 'SpecialPasswordResetOnSubmit', [ &$users, $data, &$error ] ) ) {
+                       return [ $error ];
                }
 
                $this->method = $method;
@@ -208,15 +212,15 @@ class SpecialPasswordReset extends FormSpecialPage {
                                // Don't reveal whether or not an email address is in use
                                return true;
                        } else {
-                               return array( 'noname' );
+                               return [ 'noname' ];
                        }
                }
 
                $firstUser = $users[0];
 
-               if ( !$firstUser instanceof User || !$firstUser->getID() ) {
+               if ( !$firstUser instanceof User || !$firstUser->getId() ) {
                        // Don't parse username as wikitext (bug 65501)
-                       return array( array( 'nosuchuser', wfEscapeWikiText( $data['Username'] ) ) );
+                       return [ [ 'nosuchuser', wfEscapeWikiText( $data['Username'] ) ] ];
                }
 
                // Check against the rate limiter
@@ -230,27 +234,27 @@ class SpecialPasswordReset extends FormSpecialPage {
 
                                # Round the time in hours to 3 d.p., in case someone is specifying
                                # minutes or seconds.
-                               return array( array(
+                               return [ [
                                        'throttled-mailpassword',
                                        round( $this->getConfig()->get( 'PasswordReminderResendTime' ), 3 )
-                               ) );
+                               ] ];
                        }
                }
 
                // All the users will have the same email address
                if ( $firstUser->getEmail() == '' ) {
                        // This won't be reachable from the email route, so safe to expose the username
-                       return array( array( 'noemail', wfEscapeWikiText( $firstUser->getName() ) ) );
+                       return [ [ 'noemail', wfEscapeWikiText( $firstUser->getName() ) ] ];
                }
 
                // We need to have a valid IP address for the hook, but per bug 18347, we should
                // send the user's name if they're logged in.
                $ip = $this->getRequest()->getIP();
                if ( !$ip ) {
-                       return array( 'badipaddress' );
+                       return [ 'badipaddress' ];
                }
                $caller = $this->getUser();
-               Hooks::run( 'User::mailPasswordInternal', array( &$caller, &$ip, &$firstUser ) );
+               Hooks::run( 'User::mailPasswordInternal', [ &$caller, &$ip, &$firstUser ] );
                $username = $caller->getName();
                $msg = IP::isValid( $username )
                        ? 'passwordreset-emailtext-ip'
@@ -259,7 +263,7 @@ class SpecialPasswordReset extends FormSpecialPage {
                // Send in the user's language; which should hopefully be the same
                $userLanguage = $firstUser->getOption( 'language' );
 
-               $passwords = array();
+               $passwords = [];
                foreach ( $users as $user ) {
                        $password = PasswordFactory::generateRandomPasswordString( $wgMinimalPasswordLength );
                        $user->setNewpassword( $password );
@@ -299,7 +303,7 @@ class SpecialPasswordReset extends FormSpecialPage {
                        // @todo FIXME: The email wasn't sent, but we have already set
                        // the password throttle timestamp, so they won't be able to try
                        // again until it expires...  :(
-                       return array( array( 'mailerror', $this->result->getMessage() ) );
+                       return [ [ 'mailerror', $this->result->getMessage() ] ];
                }
        }
 
@@ -314,7 +318,7 @@ class SpecialPasswordReset extends FormSpecialPage {
                                        $this->result->getMessage(), $this->firstUser->getName() );
                        }
 
-                       $this->getOutput()->addHTML( Html::rawElement( 'pre', array(), $this->email->escaped() ) );
+                       $this->getOutput()->addHTML( Html::rawElement( 'pre', [], $this->email->escaped() ) );
                }
 
                if ( $this->method === 'email' ) {