Index: trunk/phase3/includes/User.php |
— | — | @@ -624,16 +624,8 @@ |
625 | 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,14 +637,27 @@ |
646 | 638 | function getPasswordValidity( $password ) { |
647 | 639 | global $wgMinimalPasswordLength, $wgContLang; |
648 | 640 | |
649 | | - if ( !$this->isValidPassword( $password ) ) { |
| 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 ) ) { |
653 | 650 | return 'password-name-match'; |
| 651 | + } else { |
| 652 | + //it seems weird returning true here, but this is because of the |
| 653 | + //initialization of $result to false above. If the hook is never run or it |
| 654 | + //doesn't modify $result, then we will likely get down into this if with |
| 655 | + //a valid password. |
| 656 | + return true; |
654 | 657 | } |
| 658 | + } elseif( $result === true ) { |
| 659 | + return true; |
655 | 660 | } else { |
656 | | - return true; |
| 661 | + return $result; //the isValidPassword hook set a string $result and returned true |
657 | 662 | } |
658 | 663 | } |
659 | 664 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -601,6 +601,9 @@ |
602 | 602 | shared repository and only users with the 'reupload-shared' permission can |
603 | 603 | complete the move. |
604 | 604 | * (bug 18909) Add missing Postgres INSERT SELECT wrapper |
| 605 | +* User::isValidPassword now only returns boolean results, User::getPasswordValidity |
| 606 | + can be used to get an error message string |
| 607 | +* The error message shown in Special:ChangePassword now parses wiki markup |
605 | 608 | |
606 | 609 | == API changes in 1.16 == |
607 | 610 | |