From 3a9bf7e49305a1e12649685413ecefde7161d993 Mon Sep 17 00:00:00 2001 From: Elorfin Date: Wed, 11 Oct 2023 09:48:51 +0200 Subject: [PATCH] [Community] fixes users delete --- .../Subscriber/Crud/UserSubscriber.php | 2 +- .../Installation/ClarolineCoreInstaller.php | 2 ++ .../Installation/Updater/Updater140010.php | 26 +++++++++++++++++++ .../Resources/config/services/updater.yml | 4 +++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/main/core/Installation/Updater/Updater140010.php diff --git a/src/main/community/Subscriber/Crud/UserSubscriber.php b/src/main/community/Subscriber/Crud/UserSubscriber.php index 31982cde206..91463b297ff 100644 --- a/src/main/community/Subscriber/Crud/UserSubscriber.php +++ b/src/main/community/Subscriber/Crud/UserSubscriber.php @@ -263,7 +263,7 @@ public function preDelete(DeleteEvent $event) // soft delete~ $user->setRemoved(true); - $user->setEmail('email#'.$user->getId()); + $user->setEmail('email'.$user->getId().'@deleted.com'); $user->setFirstName('firstname#'.$user->getId()); $user->setLastName('lastname#'.$user->getId()); $user->setPlainPassword(uniqid()); diff --git a/src/main/core/Installation/ClarolineCoreInstaller.php b/src/main/core/Installation/ClarolineCoreInstaller.php index 78963976ab8..6cb202dafb3 100644 --- a/src/main/core/Installation/ClarolineCoreInstaller.php +++ b/src/main/core/Installation/ClarolineCoreInstaller.php @@ -12,6 +12,7 @@ namespace Claroline\CoreBundle\Installation; use Claroline\CoreBundle\Installation\Updater\Updater140000; +use Claroline\CoreBundle\Installation\Updater\Updater140010; use Claroline\CoreBundle\Library\Configuration\PlatformConfigurationHandler; use Claroline\CoreBundle\Library\Normalizer\DateNormalizer; use Claroline\InstallationBundle\Additional\AdditionalInstaller; @@ -22,6 +23,7 @@ public static function getUpdaters(): array { return [ '14.0.0' => Updater140000::class, + '14.0.10' => Updater140010::class, ]; } diff --git a/src/main/core/Installation/Updater/Updater140010.php b/src/main/core/Installation/Updater/Updater140010.php new file mode 100644 index 00000000000..9e8c1c69f84 --- /dev/null +++ b/src/main/core/Installation/Updater/Updater140010.php @@ -0,0 +1,26 @@ +connection = $connection; + } + + public function postUpdate() + { + $updateUsers = $this->connection->prepare(" + UPDATE claro_user AS u SET u.mail = CONCAT('email', CONCAT(u.id, '@deleted.com')) WHERE u.is_removed = true + "); + + $updateUsers->executeQuery(); + } +} diff --git a/src/main/core/Resources/config/services/updater.yml b/src/main/core/Resources/config/services/updater.yml index a542d131e2c..1ac4e7b576f 100644 --- a/src/main/core/Resources/config/services/updater.yml +++ b/src/main/core/Resources/config/services/updater.yml @@ -6,3 +6,7 @@ services: arguments: - '@kernel' - '@doctrine.dbal.default_connection' + + Claroline\CoreBundle\Installation\Updater\Updater140010: + arguments: + - '@doctrine.dbal.default_connection'