Index: trunk/phase3/includes/User.php |
— | — | @@ -621,19 +621,11 @@ |
622 | 622 | * Is the input a valid password for this user? |
623 | 623 | * |
624 | 624 | * @param $password String Desired password |
625 | | - * @return mixed: bool True or false or a message key explaining why the password is invalid |
| 625 | + * @return bool True or false |
626 | 626 | */ |
627 | 627 | function isValidPassword( $password ) { |
628 | | - global $wgMinimalPasswordLength, $wgContLang; |
629 | | - |
630 | | - if( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) ) |
631 | | - return $result; |
632 | | - if( $result === false ) |
633 | | - return false; |
634 | | - |
635 | | - // Password needs to be long enough, and can't be the same as the username |
636 | | - return strlen( $password ) >= $wgMinimalPasswordLength |
637 | | - && $wgContLang->lc( $password ) !== $wgContLang->lc( $this->mName ); |
| 628 | + //simple boolean wrapper for getPasswordValidity |
| 629 | + return $this->getPasswordValidity( $password ) === true; |
638 | 630 | } |
639 | 631 | |
640 | 632 | /** |
— | — | @@ -645,7 +637,12 @@ |
646 | 638 | function getPasswordValidity( $password ) { |
647 | 639 | global $wgMinimalPasswordLength, $wgContLang; |
648 | 640 | |
649 | | - if ( ( $result = $this->isValidPassword( $password ) ) === false ) { |
| 641 | + $result = false; //init $result to false for the internal checks |
| 642 | + |
| 643 | + if( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) ) |
| 644 | + return $result; |
| 645 | + |
| 646 | + if ( $result === false ) { |
650 | 647 | if( strlen( $password ) < $wgMinimalPasswordLength ) { |
651 | 648 | return 'passwordtooshort'; |
652 | 649 | } elseif ( $wgContLang->lc( $password ) == $wgContLang->lc( $this->mName ) ) { |
— | — | @@ -654,7 +651,7 @@ |
655 | 652 | } elseif( $result === true ) { |
656 | 653 | return true; |
657 | 654 | } else { |
658 | | - return $result; //the isValidPassword hook set a string $result and returned false |
| 655 | + return $result; //the isValidPassword hook set a string $result and returned true |
659 | 656 | } |
660 | 657 | } |
661 | 658 | |
— | — | @@ -1770,7 +1767,7 @@ |
1771 | 1768 | throw new PasswordError( wfMsg( 'password-change-forbidden' ) ); |
1772 | 1769 | } |
1773 | 1770 | |
1774 | | - if( $this->isValidPassword( $str ) !== true ) { |
| 1771 | + if( !$this->isValidPassword( $str ) ) { |
1775 | 1772 | global $wgMinimalPasswordLength; |
1776 | 1773 | $valid = $this->getPasswordValidity( $str ); |
1777 | 1774 | throw new PasswordError( wfMsgExt( $valid, array( 'parsemag' ), |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -598,8 +598,8 @@ |
599 | 599 | * (bug 18019) Users are now warned when moving a file to a name in use on a |
600 | 600 | shared repository and only users with the 'reupload-shared' permission can |
601 | 601 | complete the move. |
602 | | -* Any strings returned by the isValidPassword hook are now shown as error messages |
603 | | - instead of MediaWiki thinking that the hook said the password was valid. |
| 602 | +* User::isValidPassword now only returns boolean results, User::getPasswordValidity |
| 603 | + can be used to get an error message string |
604 | 604 | * The error message shown in Special:ChangePassword now parses wiki markup |
605 | 605 | |
606 | 606 | == API changes in 1.16 == |