Problem/Motivation

When

  • a user has never logged in and attempts to log in or
  • users are primarily logging in via SSO. (In that case, they do not/may not have a password for local login.)

these PHP 8 warnings are a result:

Deprecated function: substr(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Password\PhpassHashedPassword->check() (line 223 of core/lib/Drupal/Core/Password/PhpassHashedPassword.php).

Deprecated function: substr(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Password\PhpassHashedPassword->check() (line 234 of core/lib/Drupal/Core/Password/PhpassHashedPassword.php).

This is the reason:

Hint: the `pass`column in `users_field_data` database table is nullable

Function authenticate in UserAuth.php line 50 has this:
if ($this->passwordChecker->check($password, $account->getPassword())) {

If the user has never logged in, getPassword() returns null. That sends null to the $hash parameter in checkI() in PhpassHashedPassword.php. It then tries to send that to substr() causing the warning as passing null where it's expecting a string is deprecated.

Steps to reproduce

Attempt to log in with an account that has never logged in.

Proposed resolution

I'm thinking we can simply check if getPassword() returns null and skip out if it does. I think this is an edge case because the account isn't being created by the user so there is no password set. In that case, it wouldn't be possible for them to log in without requesting a password reset, anyway.

Remaining tasks

Make the patch (in progress).

User interface changes

API changes

Data model changes

None.

CommentFileSizeAuthor
#82 3305807-82.patch3.83 KBandypost
#78 3305807-78.patch3.84 KBandypost
#78 interdiff.txt1002 bytesandypost
#76 interdiff_68-76.txt1.29 KBasad_ahmed
#76 password-3305807-76.patch4.35 KBasad_ahmed
#70 password-3305807-68.patch2.93 KBxjm
#70 password-3305807-68-FAIL.patch1.53 KBxjm
#68 interdiff-68.txt3.06 KBChrisPerko
#68 password-3305807-68.patch6 KBChrisPerko
#68 password-3305807-68-FAIL.patch3.13 KBChrisPerko
#66 interdiff-66.txt3.06 KBChrisPerko
#66 password-3305807-66.patch3.06 KBChrisPerko
#66 password-3305807-66-FAIL.patch3.06 KBChrisPerko
#62 3305807-60.patch2.94 KBxjm
#62 3305807-60-FAIL.patch1.53 KBxjm
#60 interdiff-60.txt5.66 KBChrisPerko
#60 password-3305807-60.patch6.01 KBChrisPerko
#60 password-3305807-60-FAIL.patch3.14 KBChrisPerko
#51 3305807-nr-bot.txt85 bytesneeds-review-queue-bot
#49 3305807-41.patch680 bytesjessey
#40 3305807-40.patch2.71 KBsorlov
#40 3305807-38.patch2.71 KBsorlov
#38 3305807-38.patch2.78 KBsorlov
#38 interdiff-35-38.txt1.23 KBsorlov
#35 interdiff-33-35.txt5.16 KBilya.no
#35 3305807-35.patch2.76 KBilya.no
#33 3305807-33.patch3.53 KB_pratik_
#30 interdiff_24_30.txt543 bytesrishabh vishwakarma
#30 3305807-30.patch3.41 KBrishabh vishwakarma
#28 interdiff_24_28.txt484 bytesrishabh vishwakarma
#28 3305807-28.patch3.41 KBrishabh vishwakarma
#24 3305807-24.patch3.3 KBandypost
#24 interdiff.txt765 bytesandypost
#22 3305807-22.patch3.52 KBandypost
#18 3305807-18.patch3.96 KBpaulocs
#18 interdiff-15-18.txt1.72 KBpaulocs
#15 3305807-15.patch3.91 KBandypost
#15 interdiff.txt446 bytesandypost
#14 3305807-14.patch3.47 KBandypost
#14 interdiff.txt1.65 KBandypost
#13 drupal-null_password-3305807-13.patch1005 bytesdanchadwick
#6 core-3305807-6-test-only.patch1.73 KBmediabounds
#6 core-3305807-6.patch3.04 KBmediabounds
#5 core-3305807-4-test-only.patch2.1 KBmediabounds
#5 core-3305807-4.patch3.52 KBmediabounds
#4 core-3305807-3.patch1.65 KBmediabounds
#4 core-3305807-3-test-only.patch2.1 KBmediabounds
#2 core-3305807-2-null-password-fix.patch683 bytesmichelle

Issue fork drupal-3305807

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Michelle created an issue. See original summary.

michelle’s picture

Assigned: michelle » Unassigned
Status: Active » Needs review
StatusFileSize
new683 bytes

Here's the patch. Sending in empty instead of null seems to work but it may be better to add more code and just avoid calling check() all together?

Status: Needs review » Needs work

The last submitted patch, 2: core-3305807-2-null-password-fix.patch, failed testing. View results

mediabounds’s picture

Status: Needs work » Needs review
StatusFileSize
new2.1 KB
new1.65 KB

We also encountered this issue when user accounts get created outside of the normal registration process (in our case, they're getting created via the External Authentication module).

Like Michelle suggested, since the documentation for PasswordInterface::check expects to get a string for the hash, it seems we should avoid calling check altogether.

Attaching an updated patch(es) with a failing test and a fix.

mediabounds’s picture

StatusFileSize
new3.52 KB
new2.1 KB

Forgot to include the test in the full patch. Updated patches.

mediabounds’s picture

StatusFileSize
new3.04 KB
new1.73 KB

Fixing whitespace issues in previous patches.

Status: Needs review » Needs work

The last submitted patch, 6: core-3305807-6-test-only.patch, failed testing. View results

mediabounds’s picture

Status: Needs work » Needs review
mxr576’s picture

Version: 9.4.x-dev » 10.1.x-dev
Issue summary: View changes

This could also happen when users are primarily logging in via SSO. In that case, they do not/may not have a password for local login.
(I do not want to go into details about which module is used for SSO because the fact that the `pass`column in `users_field_data` database table is nullable should justify why this issue should be fixed.)

larowlan’s picture

Status: Needs review » Needs work
Issue tags: +Bug Smash Initiative, +Needs Review Queue Initiative
  1. +++ b/core/modules/user/src/Entity/User.php
    @@ -407,6 +407,7 @@ public function setExistingPassword($password) {
    +      $account_unchanged->getPassword() !== NULL &&
    
    +++ b/core/modules/user/src/UserAuth.php
    @@ -47,7 +47,7 @@ public function authenticate($username, $password) {
    +        if ($account->getPassword() !== NULL && $this->passwordChecker->check($password, $account->getPassword())) {
    

    The fact we had to do this twice in core makes me think that there may be other instances in contrib that need to allow for this.

    For that reason I think the fix should be in the password service rather than in the user module.

    If we look at the ::check method we see it passes the second argument ($hash) to substr to check
    a) if it is a legacy updated password (starts with U$'
    b) is a d7 password (starts with $S$)
    c) is a phpass/phpbb3 password (starts with '$P$' or '$H$'

    If it is none of these it returns FALSE.

    So I think the ::check method should check before it calls substr that $hash is a string and non-zero length. If it is neither of those, it can return FALSE early, as all of the substr tests will fail anyway, ending up in the default clause of the switch.

  2. +++ b/core/modules/user/tests/src/Unit/UserAuthTest.php
    @@ -280,4 +284,30 @@ public function testAddCheckToUrlForTrustedRedirectResponse(): void {
    +    $this->assertFalse($this->userAuth->authenticate($this->username, $this->password));
    

    This test doesn't have a positive assert, so in theory the code path inside the service could change, and the test would keep passing because it may no longer call the method we're asserting should never be called.

    I think this is moot anyway if we move the fix into the password check service.

    So we should remove this test and update \Drupal\Tests\Core\Password\PasswordHashingTest to add a case where $hash passed is NULL. We can then add a positive assert (e.g. assertFalse($password->check($a_password, NULL)))

jwwj’s picture

I think larowlan makes a valid point. It's the password checker that uses a method which requires a non-null value, and there might be valid use cases for the User->getPassword() method to return null. IMO it would make sense to fix this issue in the password checker instead of in UserAuth or the User entity.

reenaraghavan made their first commit to this issue’s fork.

danchadwick’s picture

StatusFileSize
new1005 bytes

Along the lines of #10, here's a patch for 9.5.2 for those users who need to move past this. My site generates all accounts programmatically, so all with null passwords. I have confirmed the patch with manual testing. This patch won't apply to D10 because of the function signature change to use the SensitiveParmeter attribute. I simply cast to string because the code body handles empty strings cleanly and quickly and the code is simpler and more concise.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new1.65 KB
new3.47 KB

A bit of clean-up for #6, hope this will address feedback on #10.1

andypost’s picture

StatusFileSize
new446 bytes
new3.91 KB

probably it needs follow-up for the interdiff because changing interface

andypost’s picture

Even if user created by drush it still can have null password, so we should change interface

andypost’s picture

paulocs’s picture

StatusFileSize
new1.72 KB
new3.96 KB

Code looks good and it fixes the errors.

Only one thing: we use snake_case for variables declared in the functions.
$userWithoutPassword = $this->createMock('Drupal\user\Entity\User');

I'm attaching a patch and the inter-diff of this change only. So I think I can move to RTBC after tests pass.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Think this one is good to go now.

quietone’s picture

Status: Reviewed & tested by the community » Needs work

I don't see that the two points in #10 have been addressed. Setting back to NW.

  1. +++ b/core/modules/user/tests/src/Unit/UserAuthTest.php
    @@ -278,4 +282,30 @@ public function testAddCheckToUrlForTrustedRedirectResponse(): void {
    + * Tests the authenticate method when the user has no stored password.

    Let's be clear that this is testing when the user password is NULL.
  2. +++ b/core/modules/user/tests/src/Unit/UserAuthTest.php
    @@ -278,4 +282,30 @@ public function testAddCheckToUrlForTrustedRedirectResponse(): void {
    +   * In https://www.drupal.org/project/drupal/issues/3305807 it was discovered
    +   * that attempting to login as a user that has no stored password will
    +   * generate PHP notices due to calling substr on a NULL value.
    

    I think testing when the password is NULL is a valid test and we don't need this extra paragraph. And especially it should not be referring to a d.o issue. I am usually all for comments but I don't think this is adding useful information. What would be useful is to add how the password can be NULL as comments in the fix.

andypost’s picture

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new3.52 KB

re-roll

smustgrave’s picture

Status: Needs review » Needs work

Think I jumped the gun too early before, that's my mistake. Moving to NW per #20

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new765 bytes
new3.3 KB

yes, this extra paragraph is useless, there's git for history

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Think this is good now.

quietone’s picture

In #20 I suggested adding a comment explaining how the password can be NULL for an existing user. I still that is worth doing.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

I don't see an answer to why this shouldn't be done in the password service asked in #10.1

Can we elaborate on why we didn't go that way?

rishabh vishwakarma’s picture

Status: Needs work » Needs review
StatusFileSize
new3.41 KB
new484 bytes

Added comment as suggested in #26

larowlan’s picture

Status: Needs review » Needs work

Still needs an answer on 10.1

rishabh vishwakarma’s picture

StatusFileSize
new3.41 KB
new543 bytes

Fixed CCF from #28

quietone’s picture

Also, needs work for #20/#26.. The changes in the patch in #3 didn't add the comment in the fix.

andypost’s picture

Basically any user created without password will have it as NULL, no idea where to document it

_pratik_’s picture

Status: Needs work » Needs review
StatusFileSize
new3.53 KB

patch #30 was not applying, Attached rerolled patch.
Unable to find comments line from #20, #26
thanks

smustgrave’s picture

Status: Needs review » Needs work

Per #31

ilya.no’s picture

Status: Needs work » Needs review
StatusFileSize
new2.76 KB
new5.16 KB

@larowlan I agree with your suggestion and here is the patch for your comment #10. I've found, that PasswordHashingTest is now LegacyPasswordHashingTest due to recent changes in password processing logic. So, I've made a change to the new service and to the old one, because as long as this code is presented it needs to work properly although it's deprecated. Please, correct me, if I'm wrong.

andypost’s picture

Thanks @ilya.no I missed this point but I checked and there's only string, empty string and NULL values possible

Moreover in context of #3050720: [Meta] Implement strict typing in existing code it can use follow-up to add deprecation if not a string|null is passed

+++ b/core/lib/Drupal/Core/Password/PhpPassword.php
@@ -45,6 +45,10 @@ public function check(#[\SensitiveParameter] $password, #[\SensitiveParameter] $
+    // Newly created account may have empty password.
+    if (!is_string($hash) || (is_string($hash) && mb_strlen($hash) === 0)) {

+++ b/core/lib/Drupal/Core/Password/PhpassHashedPasswordBase.php
@@ -242,6 +242,9 @@ public function hash(#[\SensitiveParameter] $password) {
   public function check(#[\SensitiveParameter] $password, #[\SensitiveParameter] $hash) {
+    if (!is_string($hash) || (is_string($hash) && mb_strlen($hash) === 0)) {
+      return FALSE;

I bet we can simplify it with if ($hash === NULL || $hash === '')

because it must be a string or null here

andypost’s picture

Re #10.1

Can we elaborate on why we didn't go that way?

I wanted to prevent calling service ("carbonless-optimization") as both places already checking previous argument for NULL to prevent useless function call.

I still sure we need to use the same pattern for saved hash as there's many reasons it could appear a NULL from database

sorlov’s picture

StatusFileSize
new1.23 KB
new2.78 KB

Added changes mentioned in #36

andypost’s picture

Status: Needs review » Needs work

Re #38 is wrong pat h as changes only in interdiff

sorlov’s picture

StatusFileSize
new2.71 KB
new2.71 KB

Oh, sorry, here is correct patch

sorlov’s picture

andypost’s picture

Status: Needs work » Needs review

thank you

andypost’s picture

smustgrave’s picture

Status: Needs review » Needs work

Seems part of #10 has been addressed. Think the part that @larowlan was looking for was a positive assertion somewhere.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ilya.no’s picture

Status: Needs work » Needs review

@smustgrave I'm not sure, that I've got your point. In comment #10 it's stated, that we need to add test case, which looks like

assertFalse($password->check($a_password, NULL))

In my patch I've added following code

$this->assertFalse($this->passwordHasher->check($this->password, NULL));

which looks the same, as suggestion from comment #10.

Could you correct me, if I'm wrong? Or maybe I didn't understand you. Thanks!

smustgrave’s picture

Status: Needs review » Needs work

Yes but it was request for a positive assertion. AssertTrue somewhere

sorlov’s picture

Status: Needs work » Needs review

Logic of latest patch is pretty different from what was addressed in #10

So I don't see how we could have positive assertion for latest patch logic

jessey’s picture

Version: 11.x-dev » 10.0.x-dev
StatusFileSize
new680 bytes
smustgrave’s picture

Version: 10.0.x-dev » 11.x-dev

11.x is the current dev branch.

Also #49 seems to be removing some of the original patch from 40.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new85 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

sorlov’s picture

sorlov’s picture

Status: Needs work » Needs review

Patch from #40 can be applied to 11.x as well

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Going to see what the committers think if we need to do some trickery for a positive assertion. Going to mark it so it doesn't get lost in the shuffle of things.

catch’s picture

Status: Reviewed & tested by the community » Needs work

Which patch is RTBC? 40 or 49? If it's 40, that should be re-uploaded so it's the newest patch on the issue. I think just a negative assertion is fine, we're testing there's no PHP warning.

ilya.no’s picture

Status: Needs work » Needs review

@catch RTBC is for patch #40.
Patch from comment #49 is for 10.0.x branch without any explanation and I think, that we can ignore it.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

@ilya.no hid patch 49.

So #40 should be at the top.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for working on this! A few small things:

  1. index f16eeb200c..e6863b6c3e 100644
    --- a/core/lib/Drupal/Core/Password/PhpPassword.php
    
    index 052c2be81e..2cbdb3d617 100644
    --- a/core/lib/Drupal/Core/Password/PhpassHashedPasswordBase.php
    
    @@ -242,6 +242,9 @@ public function hash(#[\SensitiveParameter] $password) {
    +    if ($hash === NULL || $hash === '') {
    +      return FALSE;
    +    }
    

    I think the same inline comment needs to be added above this hunk as well, unless we want to abstract it into a protected checkEmptyPassword() method somewhere.

  2. +++ b/core/lib/Drupal/Core/Password/PhpPassword.php
    @@ -45,6 +45,10 @@ public function check(#[\SensitiveParameter] $password, #[\SensitiveParameter] $
    +    // Newly created account may have empty password.
    

    Very minor nitpick: This is not a complete sentence, and complete sentences are required by our documentation guidelines:

    All documentation and comments should form proper sentences, use proper grammar and punctuation, and generally follow the same style guidelines as Drupal.org content: http://drupal.org/style-guide/content

    So, I think this should be:

    Newly created accounts may have empty passwords.

  3. +++ b/core/modules/phpass/tests/src/Tests/LegacyPasswordHashingTest.php
    @@ -122,4 +122,13 @@ public function testPasswordRehashing() {
    +   * Tests password check in case provided hash is NULL.
    
    Tests password validation when the hash is NULL.
  4. +++ b/core/modules/phpass/tests/src/Tests/LegacyPasswordHashingTest.php
    @@ -122,4 +122,13 @@ public function testPasswordRehashing() {
    +    $this->assertFalse($this->passwordHasher->check($this->password, NULL));
    

    Shouldn't we also cover empty string in the same method?

  5. +++ b/core/tests/Drupal/Tests/Core/Password/PhpPasswordTest.php
    @@ -124,4 +124,13 @@ public function providerLongPasswords() {
    +   * Tests password check in case provided hash is NULL.
    +   *
    +   * @covers ::check
    +   */
    +  public function testEmptyHash() {
    +    $this->assertFalse($this->passwordHasher->check($this->password, NULL));
    +  }
    

    Same comments as above.

ChrisPerko’s picture

I'm working on this issue and @xjm and @allisonherodevs are mentoring me on it.

ChrisPerko’s picture

Status: Needs work » Needs review
StatusFileSize
new3.14 KB
new6.01 KB
new5.66 KB

Addressed #58 and added return type hints to the new methods.

xjm’s picture

StatusFileSize
new1.53 KB
new2.94 KB

So I just spent 15 minutes trying to figure out what the heck was going on with #60. The patches are readable in dreditor or if opened in their own tab. However, when I try to curl them -- or even "File... Save as..." I get an empty file.

I think this is a previously-unknown-to-me security "feature" of Drupal.org in that it won't serve files with the word "password" in the name, which also means DrupalCI gets an empty patch. It's imperfect though because I can open them in the browser in Dreditor or their own tab. Weird, yo. Edit: Hypothesis false per @drumm. Instead, the files might be encoded as UTF-16 and #2922638: No charset on response for patch & text files could then mean curl (and therefore DrupalCI) don't know how to interpret it.

What I had to do was create a new file locally, copy the text from the patch opened in a tab, and paste it into my editor. I thought of naming them "hash-nid-etc.patch" but thought that could be, er, misinterpreted.) These are just versions of @ChrisPerko's patch and test-only patch that Drupal.org will deign to serve, so I'm still eligible to review/commit this when appropriate. Fun times!

Anyway, adding credit for Allison as well as the correct mentoring attribution for myself.

xjm’s picture

xjm’s picture

Looks like stuff is mis-indented which at least is easier to fix. 😂

FILE: ...ore/modules/phpass/tests/src/Tests/LegacyPasswordHashingTest.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 131 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
     |       |     found 6
     |       |     (Drupal.WhiteSpace.ScopeIndent.IncorrectExact)
 132 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
     |       |     found 6
     |       |     (Drupal.WhiteSpace.ScopeIndent.IncorrectExact)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...w/html/core/tests/Drupal/Tests/Core/Password/PhpPasswordTest.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 133 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
     |       |     found 6
     |       |     (Drupal.WhiteSpace.ScopeIndent.IncorrectExact)
 134 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
     |       |     found 6
     |       |     (Drupal.WhiteSpace.ScopeIndent.IncorrectExact)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
ChrisPerko’s picture

StatusFileSize
new3.06 KB
new3.06 KB
new3.06 KB

I fixed the spacing, I'm crossing my fingers that I created the interdiff and patches correctly.

xjm’s picture

Status: Needs review » Needs work

All three files seem to contain the interdiff. :)

ChrisPerko’s picture

Status: Needs work » Needs review
StatusFileSize
new3.13 KB
new6 KB
new3.06 KB

Hopefully this is right this time. If not, someone else can fix it, or I will get to it Monday morning. Thanks for your help @xjm

xjm’s picture

Those look like the correct patches, but they still have whatever weird encoding problem unfortunately.

xjm’s picture

StatusFileSize
new1.53 KB
new2.93 KB

Repeating what I did in #62 except with the original filenames. The interdiff is attached to #68 and works fine since DrupalCI does not need to apply it.

The last submitted patch, 70: password-3305807-68-FAIL.patch, failed testing. View results

xjm’s picture

There we go. :) Correct test failures.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Thank you, back to RTBC

The last submitted patch, 70: password-3305807-68-FAIL.patch, failed testing. View results

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

Looking much simpler, nice work.

I think we're missing a documentation update here.

Currently \Drupal\Core\Password\PasswordInterface::check documents that hash is a string, but we're now effectively saying we also support NULL. I think we should update the @parameter type-hint from string to string|null.

asad_ahmed’s picture

Status: Needs work » Needs review
StatusFileSize
new4.35 KB
new1.29 KB

I have updated the @parameter type-hint from string to string|null in core/lib/Drupal/Core/Password/PasswordInterface.php as per #75. Please review. Thanks

smustgrave’s picture

Status: Needs review » Needs work

CC failure

Saving credit for ChrisPerko for keeping this issue moving forward.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new1002 bytes
new3.84 KB

Fixed CS

+++ b/core/lib/Drupal/Core/Password/PasswordInterface.php
@@ -27,14 +27,14 @@ public function hash(#[\SensitiveParameter] $password);
    * @param string $password
-   *   A plain-text password
-   * @param string $hash
+   *   A plain-text password.
+   * @param string|null $hash

this change is out of scope a bit but I included it as part of context

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Change Looks good.

larowlan’s picture

Title: Password is null if user has never logged in which causes PHP 8 warning » [PP-1] Password is null if user has never logged in which causes PHP 8 warning
Status: Reviewed & tested by the community » Postponed
Related issues: +#3393072: Ensure Unit tests in phpass run and remove unneeded LegacyPasswordHashingTest::testInvalidArguments
+++ b/core/modules/phpass/tests/src/Tests/LegacyPasswordHashingTest.php
@@ -122,4 +122,14 @@ public function testPasswordRehashing() {
+  /**
+   * 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, ''));
+  }

This test didn't fail - and that's because of #3393072: Ensure Unit tests in phpass run and remove unneeded LegacyPasswordHashingTest::testInvalidArguments, so postponing on that

And that's because its in a Tests folder when it should be in a folder named Unit

There are two tests in that folder, and neither of them are running in HEAD

larowlan’s picture

Title: [PP-1] Password is null if user has never logged in which causes PHP 8 warning » Password is null if user has never logged in which causes PHP 8 warning
Status: Postponed » Active

Blocker is in

andypost’s picture

Status: Active » Needs review
StatusFileSize
new3.83 KB
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Reroll seems good and tests all green!

  • larowlan committed 6df2fd88 on 10.1.x
    Issue #3305807 by andypost, ChrisPerko, mediabounds, xjm, sorlov,...

  • larowlan committed d30fedcc on 10.2.x
    Issue #3305807 by andypost, ChrisPerko, mediabounds, xjm, sorlov,...

  • larowlan committed 00a619f3 on 11.x
    Issue #3305807 by andypost, ChrisPerko, mediabounds, xjm, sorlov,...
larowlan’s picture

Version: 11.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed to 11.x and backported to 10.2.x and 10.1.x

Thanks all.

The final patch was nice and small which is always a good sign

andypost’s picture

Issue tags: +PHP 8.0

Thank you! it was the last bit of PHP 8.0 compatibility! Now looking for 8.3)

andypost’s picture

Issue tags: -PHP 8.0 +PHP 8.1

sorry, the 8.1 compatibility)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

aurelianzaha’s picture

@larowlan
It would be great to backport the MR also to 10.3
if there is a way I can help on that, let me know