Merge "Fixed Style/StringLiterals RuboCop offense"
[lhc/web/wiklou.git] / includes / specials / SpecialChangePassword.php
index ad1d597..168095f 100644 (file)
@@ -43,6 +43,7 @@ class SpecialChangePassword extends FormSpecialPage {
 
        /**
         * Main execution point
+        * @param string|null $par
         */
        function execute( $par ) {
                $this->getOutput()->disallowUserJs();
@@ -77,8 +78,6 @@ class SpecialChangePassword extends FormSpecialPage {
        }
 
        protected function getFormFields() {
-               global $wgCookieExpiration;
-
                $user = $this->getUser();
                $request = $this->getRequest();
 
@@ -119,7 +118,7 @@ class SpecialChangePassword extends FormSpecialPage {
                }
 
                $extraFields = array();
-               wfRunHooks( 'ChangePasswordForm', array( &$extraFields ) );
+               Hooks::run( 'ChangePasswordForm', array( &$extraFields ) );
                foreach ( $extraFields as $extra ) {
                        list( $name, $label, $type, $default ) = $extra;
                        $fields[$name] = array(
@@ -134,8 +133,9 @@ class SpecialChangePassword extends FormSpecialPage {
                        $fields['Remember'] = array(
                                'type' => 'check',
                                'label' => $this->msg( 'remembermypassword' )
-                                               ->numParams( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) )
-                                               ->text(),
+                                               ->numParams(
+                                                       ceil( $this->getConfig()->get( 'CookieExpiration' ) / ( 3600 * 24 ) )
+                                               )->text(),
                                'default' => $request->getVal( 'wpRemember' ),
                        );
                }
@@ -230,11 +230,12 @@ class SpecialChangePassword extends FormSpecialPage {
        }
 
        /**
+        * @param string $oldpass
+        * @param string $newpass
+        * @param string $retype
         * @throws PasswordError When cannot set the new password because requirements not met.
         */
        protected function attemptReset( $oldpass, $newpass, $retype ) {
-               global $wgPasswordAttemptThrottle;
-
                $isSelf = ( $this->mUserName === $this->getUser()->getName() );
                if ( $isSelf ) {
                        $user = $this->getUser();
@@ -247,22 +248,23 @@ class SpecialChangePassword extends FormSpecialPage {
                }
 
                if ( $newpass !== $retype ) {
-                       wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'badretype' ) );
+                       Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'badretype' ) );
                        throw new PasswordError( $this->msg( 'badretype' )->text() );
                }
 
                $throttleCount = LoginForm::incLoginThrottle( $this->mUserName );
                if ( $throttleCount === true ) {
                        $lang = $this->getLanguage();
+                       $throttleInfo = $this->getConfig()->get( 'PasswordAttemptThrottle' );
                        throw new PasswordError( $this->msg( 'changepassword-throttled' )
-                               ->params( $lang->formatDuration( $wgPasswordAttemptThrottle['seconds'] ) )
+                               ->params( $lang->formatDuration( $throttleInfo['seconds'] ) )
                                ->text()
                        );
                }
 
                // @todo Make these separate messages, since the message is written for both cases
                if ( !$user->checkTemporaryPassword( $oldpass ) && !$user->checkPassword( $oldpass ) ) {
-                       wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) );
+                       Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) );
                        throw new PasswordError( $this->msg( 'resetpass-wrong-oldpass' )->text() );
                }
 
@@ -274,8 +276,8 @@ class SpecialChangePassword extends FormSpecialPage {
                // Do AbortChangePassword after checking mOldpass, so we don't leak information
                // by possibly aborting a new password before verifying the old password.
                $abortMsg = 'resetpass-abort-generic';
-               if ( !wfRunHooks( 'AbortChangePassword', array( $user, $oldpass, $newpass, &$abortMsg ) ) ) {
-                       wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'abortreset' ) );
+               if ( !Hooks::run( 'AbortChangePassword', array( $user, $oldpass, $newpass, &$abortMsg ) ) ) {
+                       Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'abortreset' ) );
                        throw new PasswordError( $this->msg( $abortMsg )->text() );
                }
 
@@ -286,9 +288,9 @@ class SpecialChangePassword extends FormSpecialPage {
 
                try {
                        $user->setPassword( $newpass );
-                       wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) );
+                       Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) );
                } catch ( PasswordError $e ) {
-                       wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'error' ) );
+                       Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'error' ) );
                        throw new PasswordError( $e->getMessage() );
                }