Skip to content
Snippets Groups Projects
Verified Commit 6df2fd88 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3305807 by andypost, ChrisPerko, mediabounds, xjm, sorlov, Rishabh...

Issue #3305807 by andypost, ChrisPerko, mediabounds, xjm, sorlov, Rishabh Vishwakarma, ilya.no, asad_ahmed, paulocs, Michelle, _pratik_, reenaraghavan, DanChadwick, smustgrave, larowlan, allisonherodevs: Password is null if user has never logged in which causes PHP 8 warning

(cherry picked from commit 00a619f3)
parent 6a68463c
No related branches found
No related tags found
10 merge requests!11628Update file MediaLibraryWidget.php,!7564Revert "Issue #3364773 by roshnichordiya, Chris Matthews, thakurnishant_06,...,!5752Issue #3275828 by joachim, quietone, bradjones1, Berdir: document the reason...,!5627Issue #3261805: Field not saved when change of 0 on string start,!5427Issue #3338518: send credentials in ajax if configured in CORS settings.,!5395Issue #3387916 by fjgarlin, Spokje: Each GitLab job exposes user email,!5217Issue #3386607 by alexpott: Improve spell checking in commit-code-check.sh,!4894Issue #3280279: Add API to allow sites to opt in to upload SVG images in CKEditor 5,!3106Issue #3017548: "Filtered HTML" text format does not support manual teaser break (<!--break-->),!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links
Pipeline #41339 failed
Pipeline: drupal

#41343

    Pipeline: drupal

    #41342

      Pipeline: drupal

      #41341

        +1
        ......@@ -27,8 +27,8 @@ public function hash(#[\SensitiveParameter] $password);
        * Check whether a plain text password matches a hashed password.
        *
        * @param string $password
        * A plain-text password
        * @param string $hash
        * A plain-text password.
        * @param string|null $hash
        * A hashed password.
        *
        * @return bool
        ......@@ -46,7 +46,7 @@ public function check(#[\SensitiveParameter] $password, #[\SensitiveParameter] $
        * This method returns TRUE if the password was hashed with an older
        * algorithm.
        *
        * @param string $hash
        * @param string|null $hash
        * The hash to be checked.
        *
        * @return bool
        ......
        ......@@ -45,6 +45,10 @@ public function check(#[\SensitiveParameter] $password, #[\SensitiveParameter] $
        if (strlen($password) > static::PASSWORD_MAX_LENGTH) {
        return FALSE;
        }
        // Newly created accounts may have empty passwords.
        if ($hash === NULL || $hash === '') {
        return FALSE;
        }
        return password_verify($password, $hash);
        }
        ......
        ......@@ -242,6 +242,10 @@ public function hash(#[\SensitiveParameter] $password) {
        * {@inheritdoc}
        */
        public function check(#[\SensitiveParameter] $password, #[\SensitiveParameter] $hash) {
        // Newly created accounts may have empty passwords.
        if ($hash === NULL || $hash === '') {
        return FALSE;
        }
        if (substr($hash, 0, 2) == 'U$') {
        // This may be an updated password from user_update_7000(). Such hashes
        // have 'U' added as the first character and need an extra md5() (see the
        ......
        ......@@ -114,4 +114,14 @@ public function testPasswordRehashing() {
        $this->assertTrue($this->passwordHasher->check($this->password, $rehashed_password), 'Password check succeeds with re-hashed password with original hasher.');
        }
        /**
        * Tests password validation when the hash is NULL.
        *
        * @covers ::check
        */
        public function testEmptyHash(): void {
        $this->assertFalse($this->passwordHasher->check($this->password, NULL));
        $this->assertFalse($this->passwordHasher->check($this->password, ''));
        }
        }
        ......@@ -124,4 +124,14 @@ public function providerLongPasswords() {
        return $passwords;
        }
        /**
        * Tests password check in case provided hash is NULL.
        *
        * @covers ::check
        */
        public function testEmptyHash(): void {
        $this->assertFalse($this->passwordHasher->check($this->password, NULL));
        $this->assertFalse($this->passwordHasher->check($this->password, ''));
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment