Skip to content

Commit

Permalink
do not initialize memberStorageId in UserManager::constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Nov 19, 2024
1 parent b24f6e8 commit 695e9cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
14 changes: 7 additions & 7 deletions src/Manager/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 695e9cb

Please sign in to comment.