Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / specials / SpecialChangeEmail.php
index 51b08f9..b35446d 100644 (file)
@@ -36,6 +36,10 @@ class SpecialChangeEmail extends FormSpecialPage {
                parent::__construct( 'ChangeEmail', 'editmyprivateinfo' );
        }
 
+       public function doesWrites() {
+               return true;
+       }
+
        /**
         * @return bool
         */
@@ -77,30 +81,30 @@ class SpecialChangeEmail extends FormSpecialPage {
        protected function getFormFields() {
                $user = $this->getUser();
 
-               $fields = array(
-                       'Name' => array(
+               $fields = [
+                       'Name' => [
                                'type' => 'info',
                                'label-message' => 'username',
                                'default' => $user->getName(),
-                       ),
-                       'OldEmail' => array(
+                       ],
+                       'OldEmail' => [
                                'type' => 'info',
                                'label-message' => 'changeemail-oldemail',
                                'default' => $user->getEmail() ?: $this->msg( 'changeemail-none' )->text(),
-                       ),
-                       'NewEmail' => array(
+                       ],
+                       'NewEmail' => [
                                'type' => 'email',
                                'label-message' => 'changeemail-newemail',
                                'autofocus' => true,
                                'help-message' => 'changeemail-newemail-help',
-                       ),
-               );
+                       ],
+               ];
 
                if ( $this->getConfig()->get( 'RequirePasswordforEmailChange' ) ) {
-                       $fields['Password'] = array(
+                       $fields['Password'] = [
                                'type' => 'password',
                                'label-message' => 'changeemail-password'
-                       );
+                       ];
                }
 
                return $fields;
@@ -169,13 +173,12 @@ class SpecialChangeEmail extends FormSpecialPage {
                        return Status::newFatal( 'changeemail-nochange' );
                }
 
-               $throttleCount = LoginForm::incLoginThrottle( $user->getName() );
-               if ( $throttleCount === true ) {
+               $throttleInfo = LoginForm::incrementLoginThrottle( $user->getName() );
+               if ( $throttleInfo ) {
                        $lang = $this->getLanguage();
-                       $throttleInfo = $this->getConfig()->get( 'PasswordAttemptThrottle' );
                        return Status::newFatal(
                                'changeemail-throttled',
-                               $lang->formatDuration( $throttleInfo['seconds'] )
+                               $lang->formatDuration( $throttleInfo['wait'] )
                        );
                }
 
@@ -186,9 +189,7 @@ class SpecialChangeEmail extends FormSpecialPage {
                        return Status::newFatal( 'wrongpassword' );
                }
 
-               if ( $throttleCount ) {
-                       LoginForm::clearLoginThrottle( $user->getName() );
-               }
+               LoginForm::clearLoginThrottle( $user->getName() );
 
                $oldaddr = $user->getEmail();
                $status = $user->setEmailWithConfirmation( $newaddr );
@@ -196,7 +197,7 @@ class SpecialChangeEmail extends FormSpecialPage {
                        return $status;
                }
 
-               Hooks::run( 'PrefsEmailAudit', array( $user, $oldaddr, $newaddr ) );
+               Hooks::run( 'PrefsEmailAudit', [ $user, $oldaddr, $newaddr ] );
 
                $user->saveSettings();