Problem/Motivation

When I'm trying to login, I receive this error:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function id() on array in Drupal\openid_connect\OpenIDConnect->saveUserinfo() (line 696 of modules/contrib/openid_connect/src/OpenIDConnect.php).

Steps to reproduce

Proposed resolution

Current implementation:

$account_by_mail = $this->userStorage->loadByProperties(['mail' => $claim_value]);
if (empty($account_by_mail) || ($account_by_mail->id() == $account->id())) {

Proposed improvement (use current() in second if condition):

$account_by_mail = $this->userStorage->loadByProperties(['mail' => $claim_value]);
if (empty($account_by_mail) || (current($account_by_mail)->id() == $account->id())) {
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

gugalamaciek created an issue. See original summary.

gugalamaciek’s picture

Patch for proposed resolution:

gugalamaciek’s picture

Assigned: gugalamaciek » Unassigned
Status: Active » Needs review
danflanagan8’s picture

Status: Needs review » Reviewed & tested by the community

I ran into this exact problem. The patch looks fine and fixed my problem. It would be awesome to have test coverage, but there's not a ton of test coverage in the module to begin with. I don't see any existing test that would be easy to modify or copy/paste. So let's just RTBC this as is.

In case it's not clear from the IS, this is triggered when mail gets added to the userinfo_mappings in openid_connect and openid_connect_user_properties_ignore_alter is being used to un-ignore the mail property.

I was actually surprised it took so much work to allow a user's email to update during login.

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

pfrilling’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Chicago2026

I added tests validating the fix. Thanks for the patches!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • pfrilling committed 0eccea69 on 3.x
    fix: #3400244 Error on OpenIDConnect::saveUserinfo() when trying use...

Status: Fixed » Closed (fixed)

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