Integrity constraint violation: 1048 Column 'name' cannot be null: INSERT INTO "users_field_data".

Created on 12 January 2023, almost 2 years ago
Updated 7 April 2024, 8 months ago

Problem/Motivation

SQL Error when Admin updating someone's password using change password page with Password Policy enable.

Error message

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null: INSERT INTO "users_field_data" ("uid", "langcode", "preferred_langcode", "preferred_admin_langcode", "name", "pass", "mail", "timezone", "status", "created", "changed", "access", "login", "init", "default_langcode", "content_translation_source", "content_translation_outdated", "content_translation_uid", "content_translation_status", "content_translation_created") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19); Array ( [:db_insert_placeholder_0] => 9 [:db_insert_placeholder_1] => es [:db_insert_placeholder_2] => es [:db_insert_placeholder_3] => es [:db_insert_placeholder_4] => [:db_insert_placeholder_5] => $S$Ek4aZ/l.OOAyGWuPiL78pW/FKD/lqaq0EztMZ9xtn3Y8JeGw8bQe [:db_insert_placeholder_6] => makbul.khan8@gmail.com [:db_insert_placeholder_7] => America/Argentina/Buenos_Aires [:db_insert_placeholder_8] => 1 [:db_insert_placeholder_9] => 1634645298 [:db_insert_placeholder_10] => 1673513738 [:db_insert_placeholder_11] => 1673510820 [:db_insert_placeholder_12] => 1673509019 [:db_insert_placeholder_13] => makbul.khan8@gmail.com [:db_insert_placeholder_14] => 1 [:db_insert_placeholder_15] => und [:db_insert_placeholder_16] => 0 [:db_insert_placeholder_17] => 0 [:db_insert_placeholder_18] => 1 [:db_insert_placeholder_19] => 1634645298 ) en Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (linea 811 de /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Steps to reproduce

Steps to reproduce
1. Enable Password Policy 8.x-4.0
2. Enable Change Password Page 8.x-1.0
3. Create a default password policy with default setting.
4. Edit user with role for which password policy is enabled password.

Proposed resolution

  // set username if form_state name value is empty
  if (empty($form_state->getValue('name'))) {
    $user->setUsername($form_state->getValue('name', $user->name->value));
  }

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed: needs info

Version

4.0

Component

Code

Created by

🇮🇳India makbul_khan8

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024