- π΅πΉPortugal jrochate
I also had this problem when using feeds to update users that were previously created/updated using LDAP Users module.
Since this problem is set by the ldap_user_user_presave() I have made a patch to make an exception when using feeds JSON to update users.
function ldap_user_user_presave($account) { + // Exclude this hook when using feeds to update users + $current_route = \Drupal::routeMatch()->getRouteName(); + if (!empty($current_route) && ($current_route !== "system.batch_page.json")) { /** @var \Drupal\ldap_user\Processor\DrupalUserProcessor $processor */ $processor = \Drupal::service('ldap.drupal_user_processor');
I hope this quick fix can help some else on the same situation.
- πͺπΈSpain unstatu
Thanks for the issue. It helped me a lot.
I think this is an issue that should be fixed with a more generic solution, don't you? If this problem affects to each place in the codebase where several users are updated, it could be anywhere.
I have implemented a solution that fixes the problem via an EventSubscriber. I'm not sure if this solution has any side effect. I don't understand why the \Drupal\ldap_user\Processor\DrupalUserProcessor reset is not managed directly in the `ldap_user_user_update` hook, for example. It could be done in purpose by the module maintainers because of any reason that I am not aware of or it may be a bug. If someone could clarify, would be great.
In any case, here you can find how I fixed the problem in a more generic way.
namespace Drupal\MY_MODULE\EventSubscriber; use Drupal\ldap_user\Event\LdapUserUpdatedEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Event subscriber for the LDAP related events. */ class LDAPSubscriber implements EventSubscriberInterface { /** * {@inheritDoc} */ public static function getSubscribedEvents() { return [ LdapUserUpdatedEvent::EVENT_NAME => 'userUpdated', ]; } /** * Takes actions after the user is saved. * * Fixes https://www.drupal.org/project/ldap/issues/3196170. * * @param \Drupal\ldap_user\Event\LdapUserUpdatedEvent $event * The user updated event. */ public function userUpdated(LdapUserUpdatedEvent $event) { \Drupal::service('ldap.drupal_user_processor')->reset(); } }
Don't forget to declare the services in the my_module.services.yml file:
services: Drupal\MY_MODULE\EventSubscriber\LDAPSubscriber: tags: - { name: event_subscriber }
- First commit to issue fork.
- π³πΏNew Zealand heathergaye
Fork has a fix in the ldap user processing. Issue was that an account could be passed into the processor, but the ldapEntry wasn't reset.
- Status changed to Postponed: needs info
about 1 year ago 5:55pm 3 October 2023 - πΊπΈUnited States bluegeek9
I think this might be solved by π EntityStorageException: User Fixed . Can anyone confirm the issue occurs with 8.x-4.x?
- Status changed to Closed: outdated
about 1 year ago 2:00pm 3 November 2023