Fatal errors on account creation - restore isAnonymous check

Created on 13 February 2024, 9 months ago

This is a follow up to the comment I raised in #3371850. The fix that was merged for this issue introduces some additional problems.

#3371850 introduced a fix for a change in behaviour in Drupal Core which caused a fatal error in account creation. The fix that was merged checks isAuthenticated instead of the previous isAnonymous. However, this is not semantically the same, and breaks compatibility with modules that may swap out the implementation of isAuthenticated.

For example, the decoupled_auth module allows the concept of users without logins (eg for CRM systems where a user record may exist for CRM purposes, but not have a login attached to it), to do this it switches out the logic of isAuthenticated.
The previously merged fix means that the decoupled_auth module no longer works with profile as these users can't have profiles attached to them.

Rather than checking isAuthenticated I'd recommend checking isAnonymous but also check isNew as well. This has semantically the same meaning as the original code prior to the fix, and works correctly with Core's change, but without assuming the meaning of isAuthenticated.

🐛 Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom JeremySkinner

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

Comments & Activities

Production build 0.71.5 2024