From: Alexandre Emsenhuber Date: Tue, 25 Jan 2011 15:36:36 +0000 (+0000) Subject: Allow the $result parameter of the isValidPassword hook to be an array if the message... X-Git-Tag: 1.31.0-rc.0~32373 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=bc650e89e7cbd090707fbc3f854985ebdbf95d2a;p=lhc%2Fweb%2Fwiklou.git Allow the $result parameter of the isValidPassword hook to be an array if the message requires parameters --- diff --git a/includes/User.php b/includes/User.php index fc9dbb2be7..0b4cf361e5 100644 --- a/includes/User.php +++ b/includes/User.php @@ -599,7 +599,7 @@ class User { * Given unvalidated password input, return error message on failure. * * @param $password String Desired password - * @return mixed: true on success, string of error message on failure + * @return mixed: true on success, string or array of error message on failure */ function getPasswordValidity( $password ) { global $wgMinimalPasswordLength, $wgContLang; @@ -1771,8 +1771,14 @@ class User { if( !$this->isValidPassword( $str ) ) { global $wgMinimalPasswordLength; $valid = $this->getPasswordValidity( $str ); - throw new PasswordError( wfMsgExt( $valid, array( 'parsemag' ), - $wgMinimalPasswordLength ) ); + if ( is_array( $valid ) ) { + $message = array_shift( $valid ); + $params = $valid; + } else { + $message = $valid; + $params = array( $wgMinimalPasswordLength ); + } + throw new PasswordError( wfMsgExt( $message, array( 'parsemag' ), $params ) ); } } diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index 768ce0ee82..d1b7f51169 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -701,7 +701,7 @@ class WebInstaller_Name extends WebInstallerPage { $msg = $valid; } if ( $msg !== false ) { - $this->parent->showError( $msg ); + call_user_func_array( array( $this->parent, 'showError' ), (array)$msg ); $this->setVar( '_AdminPassword', '' ); $this->setVar( '_AdminPassword2', '' ); $retVal = false; diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 69f55aa592..63abc8f6ed 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -327,7 +327,14 @@ class LoginForm extends SpecialPage { $valid = $u->getPasswordValidity( $this->mPassword ); if ( $valid !== true ) { if ( !$this->mCreateaccountMail ) { - $this->mainLoginForm( wfMsgExt( $valid, array( 'parsemag' ), $wgMinimalPasswordLength ) ); + if ( is_array( $valid ) ) { + $message = array_shift( $valid ); + $params = $valid; + } else { + $message = $valid; + $params = array( $wgMinimalPasswordLength ); + } + $this->mainLoginForm( wfMsgExt( $message, array( 'parsemag' ), $params ) ); return false; } else { # do not force a password for account creation by email