From c3b35bb187d99d77d9363ce9d0ccde1e1e063ffa Mon Sep 17 00:00:00 2001 From: Reedy Date: Mon, 16 Nov 2015 20:47:15 +0000 Subject: [PATCH] Improve error message if check not defined for a password policy. Bug: T118776 Change-Id: Ic1826f15424197545f4d6c2b1af49adbc4289e15 --- includes/password/UserPasswordPolicy.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/password/UserPasswordPolicy.php b/includes/password/UserPasswordPolicy.php index 80dc66920d..d57adb8e15 100644 --- a/includes/password/UserPasswordPolicy.php +++ b/includes/password/UserPasswordPolicy.php @@ -56,7 +56,7 @@ class UserPasswordPolicy { foreach ( $checks as $statement => $check ) { if ( !is_callable( $check ) ) { throw new InvalidArgumentException( - 'Policy check functions must be callable' + "Policy check functions must be callable. '$statement' isn't callable." ); } $this->policyCheckFunctions[$statement] = $check; @@ -105,11 +105,18 @@ class UserPasswordPolicy { ); } + /** + * @param User $user + * @param string $password + * @param array $policies + * @param array $policyCheckFunctions + * @return Status + */ private function checkPolicies( User $user, $password, $policies, $policyCheckFunctions ) { $status = Status::newGood(); foreach ( $policies as $policy => $value ) { if ( !isset( $policyCheckFunctions[$policy] ) ) { - throw new DomainException( 'Invalid password policy config' ); + throw new DomainException( "Invalid password policy config. No check defined for '$policy'." ); } $status->merge( call_user_func( -- 2.20.1