r58266 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58265‎ | r58266 | r58267 >
Date:17:53, 28 October 2009
Author:skizzerz
Status:ok (Comments)
Tags:
Comment:
* re-commit r58172 with the fix for the issue mentioned where users would not be able to log in
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -624,16 +624,8 @@
625625 * @return bool True or false
626626 */
627627 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;
638630 }
639631
640632 /**
@@ -645,14 +637,27 @@
646638 function getPasswordValidity( $password ) {
647639 global $wgMinimalPasswordLength, $wgContLang;
648640
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 ) {
650647 if( strlen( $password ) < $wgMinimalPasswordLength ) {
651648 return 'passwordtooshort';
652649 } elseif ( $wgContLang->lc( $password ) == $wgContLang->lc( $this->mName ) ) {
653650 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;
654657 }
 658+ } elseif( $result === true ) {
 659+ return true;
655660 } else {
656 - return true;
 661+ return $result; //the isValidPassword hook set a string $result and returned true
657662 }
658663 }
659664
Index: trunk/phase3/RELEASE-NOTES
@@ -601,6 +601,9 @@
602602 shared repository and only users with the 'reupload-shared' permission can
603603 complete the move.
604604 * (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
605608
606609 == API changes in 1.16 ==
607610

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r58172* User::isValidPassword now only returns boolean results, User::getPasswordVa...skizzerz23:19, 26 October 2009

Comments

#Comment by 😂 (talk | contribs)   07:31, 28 November 2009

This all looks ok (finally), and nobody has complained about regressions. Tentatively marking this ok.

Status & tagging log