diff --git a/UPGRADE.md b/UPGRADE.md index 3d97a43d..e9481117 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 ca0074c7..c4801208 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');