From bd7e0987bcd22f2ba79b0125ea1bc0a8eed685dc Mon Sep 17 00:00:00 2001 From: Thibaud Fabre Date: Thu, 29 Sep 2016 09:57:48 +0200 Subject: [PATCH] Clear log repository on user deletion --- lib/Alchemy/Phrasea/Model/Manager/UserManager.php | 8 ++++++-- .../Alchemy/Tests/Phrasea/Functional/UserDeletionTest.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php index eb44ee1349..d78d68bdef 100644 --- a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php +++ b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php @@ -11,6 +11,7 @@ namespace Alchemy\Phrasea\Model\Manager; +use Alchemy\Phrasea\Model\Entities\ApiLog; use Doctrine\Common\Persistence\ObjectManager; use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\UserSetting; @@ -44,7 +45,7 @@ class UserManager * Deletes an user. * * @param User $user - * @param type $flush + * @param bool $flush */ public function delete(User $user, $flush = true) { @@ -52,8 +53,10 @@ class UserManager $this->cleanRights($user); $this->objectManager->persist($user); + if ($flush) { $this->objectManager->flush(); + $this->objectManager->clear(ApiLog::class); } } @@ -61,11 +64,12 @@ class UserManager * Updates an user. * * @param User $user - * @param type $flush + * @param bool $flush */ public function update(User $user, $flush = true) { $this->objectManager->persist($user); + if ($flush) { $this->objectManager->flush(); } diff --git a/tests/Alchemy/Tests/Phrasea/Functional/UserDeletionTest.php b/tests/Alchemy/Tests/Phrasea/Functional/UserDeletionTest.php index 5ac42170c7..2db0eefa19 100644 --- a/tests/Alchemy/Tests/Phrasea/Functional/UserDeletionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Functional/UserDeletionTest.php @@ -79,7 +79,7 @@ class UserDeletionTest extends \PhraseanetAuthenticatedWebTestCase $apiLog = $apiLogManipulator->create($account, new Request(), new Response()); $apiLogId = $apiLog->getId(); - $this->userManipulator->delete($this->user); + $this->userManipulator->delete($this->user, true); $this->assertTrue($this->user->isDeleted(), 'User was not properly deleted'); $apiLogRepository->clear();