* re-commit r58172 with the fix for the issue mentioned where users would not be...
authorRyan Schmidt <skizzerz@users.mediawiki.org>
Wed, 28 Oct 2009 17:53:36 +0000 (17:53 +0000)
committerRyan Schmidt <skizzerz@users.mediawiki.org>
Wed, 28 Oct 2009 17:53:36 +0000 (17:53 +0000)
RELEASE-NOTES
includes/User.php

index 3e0708e..e3ca123 100644 (file)
@@ -601,6 +601,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   shared repository and only users with the 'reupload-shared' permission can
   complete the move.
 * (bug 18909) Add missing Postgres INSERT SELECT wrapper
+* User::isValidPassword now only returns boolean results, User::getPasswordValidity
+  can be used to get an error message string
+* The error message shown in Special:ChangePassword now parses wiki markup
 
 == API changes in 1.16 ==
 
index d4cfbd7..8435414 100644 (file)
@@ -624,16 +624,8 @@ class User {
         * @return bool True or false
         */
        function isValidPassword( $password ) {
-               global $wgMinimalPasswordLength, $wgContLang;
-
-               if( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) )
-                       return $result;
-               if( $result === false )
-                       return false;
-               // Password needs to be long enough, and can't be the same as the username
-               return strlen( $password ) >= $wgMinimalPasswordLength
-                       && $wgContLang->lc( $password ) !== $wgContLang->lc( $this->mName );
+               //simple boolean wrapper for getPasswordValidity
+               return $this->getPasswordValidity( $password ) === true;
        }
 
        /**
@@ -645,14 +637,27 @@ class User {
        function getPasswordValidity( $password ) {
                global $wgMinimalPasswordLength, $wgContLang;
                
-               if ( !$this->isValidPassword( $password ) ) {
+               $result = false; //init $result to false for the internal checks
+               
+               if( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) )
+                       return $result;
+               
+               if ( $result === false ) {
                        if( strlen( $password ) < $wgMinimalPasswordLength ) {
                                return 'passwordtooshort';
                        } elseif ( $wgContLang->lc( $password ) == $wgContLang->lc( $this->mName ) ) {
                                return 'password-name-match';
+                       } else {
+                               //it seems weird returning true here, but this is because of the
+                               //initialization of $result to false above. If the hook is never run or it
+                               //doesn't modify $result, then we will likely get down into this if with
+                               //a valid password.
+                               return true;
                        }
-               } else {
+               } elseif( $result === true ) {
                        return true;
+               } else {
+                       return $result; //the isValidPassword hook set a string $result and returned true
                }
        }