PasswordPolicyValidator::validatePassword() doesn't return the declared value

Created on 12 October 2022, about 2 years ago
Updated 8 April 2024, 9 months ago

Problem/Motivation

PasswordPolicyValidatorInterface::validatePassword() is documented to return PasswordPolicyValidationReport, while PasswordPolicyValidator::validatePassword() returns TRUE when the password is too long.

  /**
   * @return \Drupal\password_policy\PasswordPolicyValidationReport
   *   Validation report object.
   */
  public function validatePassword(string $password, UserInterface $user, array $edited_user_roles = []): PasswordPolicyValidationReport;
  /**
   * {@inheritdoc}
   */
  public function validatePassword(string $password, UserInterface $user, array $edited_user_roles = []): PasswordPolicyValidationReport {
    // Stop before policy-based validation if password exceeds maximum length.
    if (strlen($password) > PasswordInterface::PASSWORD_MAX_LENGTH) {
      return TRUE;
    }

Proposed resolution

Change the @return line in the interface.

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇵🇱Poland ivanhelguera

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024