Problem/Motivation
During cron runs, synchronizing against LDAP, if an account in LDAP has the same email as an account in Drupal but different dn, the process aborts when it gets to that account and no other accounts are processed.
Steps to reproduce
Existing account in Drupal as DOEJ with email john.doe@email.com and account in LDAP as DOEJO with email john.doe@email.com
[error] LDAP user DOEJO has email address (john.doe@email.com) conflict with a Drupal user DOEJ
[warning] array_flip(): Can only flip STRING and INTEGER values! EntityStorageBase.php:261
[error] TypeError: Argument 1 passed to Drupal\ldap_user\Processor\DrupalUserProcessor::drupalUserLogsIn() must implement interface Drupal\user\UserInterface, null given, called in /var/www/html/web/modules/contrib/ldap/ldap_user/src/Processor/GroupUserUpdateProcessor.php on line 302 in Drupal\ldap_user\Processor\DrupalUserProcessor->drupalUserLogsIn() (line 431 of /var/www/html/web/modules/contrib/ldap/ldap_user/src/Processor/DrupalUserProcessor.php) #0 /var/www/html/web/modules/contrib/ldap/ldap_user/src/Processor/GroupUserUpdateProcessor.php(302): Drupal\ldap_user\Processor\DrupalUserProcessor->drupalUserLogsIn()
#1 /var/www/html/web/modules/contrib/ldap/ldap_user/src/Processor/GroupUserUpdateProcessor.php(246): Drupal\ldap_user\Processor\GroupUserUpdateProcessor->processAccount()
#2 /var/www/html/web/modules/contrib/ldap/ldap_user/ldap_user.module(42): Drupal\ldap_user\Processor\GroupUserUpdateProcessor->runQuery()
#3 [internal function]: ldap_user_cron()
...
[warning] Drush command terminated abnormally.
I have tried to trace the flow through the code, and it looks as though the request goes into GroupUserUpdateProcessor.php processAccount, where there is no match on uid, so $result = $this->drupalUserProcessor->createDrupalUserFromLdapEntry is called.
This function returns a result of true, even though the create process failed due to the email conflict. The failure actually occurs within DrupalUserProcessor.php createDrupalUser function, but is not passed up to createDrupalUserFromLdapEntry or back to processAccount.
Ideally the error would be caught sooner in the process, but as a workaround, I have found that a second check of the uid at line 288 of GroupUserUpdateProcessor.php will catch the failure and the process can be logged for the account in question, allowing the rest of the job to complete.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | ldap-duplicate-email-3279539-2.patch | 719 bytes | risse |
| #4 | ldap-duplicate-email-3279539.patch | 675 bytes | risse |
| #3 | GroupUserUpdateProcessor.patch | 516 bytes | brandon- |
Issue fork ldap-3279539
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
Comment #2
brandon- commentedComment #3
brandon- commentedOne possible solution would be a patch similar to the attached, though this is catching the error quite far from where it happens.
Comment #4
risse commentedI am running into this same bug. Here is a reworked patch from Brandon- that should cleanly apply to 8.x-4.3
Comment #5
risse commentedFixed previous comment's patch file
Comment #6
bluegeek9 commented