From 0beb8d6c241740569f112c5601072c0434363a26 Mon Sep 17 00:00:00 2001 From: Ludmil Simeonov Date: Tue, 31 Jul 2018 12:09:38 +0300 Subject: [PATCH] Compute changeSet only for the history class Some readme additions. --- README.md | 5 +++++ src/EventListener/PasswordEntityListener.php | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 786d4a9..7391a03 100644 --- a/README.md +++ b/README.md @@ -63,3 +63,8 @@ password_policy: ##### Expiry Expiry works by checking last password change on every request made to the app, excluding those configured in the application + +##### Good to know +The library uses doctrine lifecycle events to create password history and set last password change on the target entities. +In order for this to happen we use the onFlush event and we are recalculating the history change set inside it. +You must be aware of that as any entity changes after the recalculation will not be persisted to the database. \ No newline at end of file diff --git a/src/EventListener/PasswordEntityListener.php b/src/EventListener/PasswordEntityListener.php index a9aa683..e4f5551 100644 --- a/src/EventListener/PasswordEntityListener.php +++ b/src/EventListener/PasswordEntityListener.php @@ -139,7 +139,9 @@ public function createPasswordHistory( } $em->persist($history); - $uow->computeChangeSets(); + + $metadata = $em->getClassMetadata($historyClass); + $uow->computeChangeSet($metadata, $history); $entity->setPasswordChangedAt(new \DateTime());