EntityStorageException: User

Created on 26 July 2023, 11 months ago
Updated 3 October 2023, 9 months ago

Problem/Motivation

The account data is cached. When updating multiple users in the same http request all subsequent users will be synced against the first user's data causing the error below.

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'username-en' for key 'users_field_data.user__name': INSERT INTO "users_field_data"

Steps to reproduce

One admin/people, try to update more than one user; use the bulk update feature.

Proposed resolution

Reset if the account is different.

  public function drupalUserUpdate(UserInterface $account): void {
    if ($this->account && $this->account->id() != $account->id()) {
      $this->reset();
    }

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bluegeek9

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

Comments & Activities

Production build 0.69.0 2024