Parser fails with 'Integrity constraint violation: 1062 Duplicate entry' error

Created on 17 October 2023, over 1 year ago
Updated 18 October 2023, over 1 year ago

Problem/Motivation

drush dosd:parse command fails with "Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry" when a user already exists.

That happens because userLookup() relies only on 'dorg_username' and 'dorg_link' properties to check Drupal user existence before creating a new one.

Steps to reproduce

Case '1':

  1. Run the parser
  2. Make sure a number of users were created.
  3. Uninstall DOSD.
  4. Install the module
  5. Run the parser with the same parameters

Case '2':

  1. Run the parser
  2. Make sure a number of users were created.
  3. Write down usernames and delete the users above.
  4. Manually create some users from the lost
  5. Run the parser with the same parameters

observe "Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry"

Proposed resolution

  1. Store Drupal.org UID as a main identifier for Drupal.Org user. It's important because user can change username (and URL respectively.)
  2. Check user existence in the following order: 'dorg_uid', 'dorg_username' and 'dorg_link' (the current criteria), 'name'

Data model changes

'dorg_uid' base field is added to the 'user' entity.

🐛 Bug report
Status

Fixed

Component

Code

Created by

🇷🇸Serbia SAVEL

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

Comments & Activities

Production build 0.71.5 2024