From 7c096723ade8854de216dfa1781ba1d108d471a5 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Tue, 19 Nov 2024 22:06:18 +0100 Subject: [PATCH] do not initialize memberStorageId in UserManager::constructor (#205) --- UPGRADE.md | 2 ++ src/Manager/UserManager.php | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 3d97a43..e948111 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,4 +1,6 @@ # Upgrade Notes +### 5.0.3 +- **[BUGFIX]**: Do not initialize `memberStorageId` in UserManager::constructor to prevent early db connection ### 5.0.2 - **[IMPROVEMENT]**: RoleOptionsProvider now shows the default role in UserGroup objects if no configuration was made [#201](https://github.com/dachcom-digital/pimcore-members/issues/201) diff --git a/src/Manager/UserManager.php b/src/Manager/UserManager.php index ca0074c..c480120 100644 --- a/src/Manager/UserManager.php +++ b/src/Manager/UserManager.php @@ -11,17 +11,11 @@ class UserManager implements UserManagerInterface { protected Configuration $configuration; protected ClassManagerInterface $classManager; - protected int $memberStorageId; public function __construct(Configuration $configuration, ClassManagerInterface $classManager) { $this->configuration = $configuration; $this->classManager = $classManager; - - $storagePath = $configuration->getConfig('storage_path'); - if (($membersStoreObject = DataObject::getByPath($storagePath)) instanceof DataObject\Folder) { - $this->memberStorageId = $membersStoreObject->getId(); - } } public function getClass(): string @@ -187,10 +181,16 @@ public function updateUser(UserInterface $user, array $properties = []): UserInt private function setupNewUser(UserInterface $user, ?string $key): UserInterface { + $memberStorageId = null; $validKey = $key ?? $user->getEmail(); + $storagePath = $this->configuration->getConfig('storage_path'); + if (($membersStoreObject = DataObject::getByPath($storagePath)) instanceof DataObject\Folder) { + $memberStorageId = $membersStoreObject->getId(); + } + $user->setKey(\Pimcore\File::getValidFilename($validKey)); - $user->setParentId($this->memberStorageId); + $user->setParentId($memberStorageId); $userGroups = []; $userConfiguration = $this->configuration->getConfig('user');