Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 3818f70

Browse files
committed
Merge branch '1.5'
2 parents a411975 + 17590c2 commit 3818f70

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/system/UsersModule/Entity/Repository/UserRepository.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ public function persistAndFlush(UserEntity $user)
4141

4242
public function removeAndFlush(UserEntity $user)
4343
{
44-
foreach ($user->getAttributes() as $attribute) {
45-
// this should be unnecessary because cascade = all but MySQL 5.7 not working with that
46-
$this->_em->remove($attribute);
47-
}
44+
// the following process should be unnecessary because cascade = all but MySQL 5.7 not working with that (#3726)
45+
$qb = $this->_em->createQueryBuilder();
46+
$qb->delete('Zikula\UsersModule\Entity\UserAttributeEntity', 'a')
47+
->where('a.user = :userId')
48+
->setParameter('userId', $user->getUid());
49+
$query = $qb->getQuery();
50+
$query->execute();
51+
// end of theoretically unrequired process
52+
53+
$user->setAttributes(new ArrayCollection());
4854
$this->_em->remove($user);
4955
$this->_em->flush($user);
5056
}

src/system/UsersModule/Entity/UserEntity.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,9 @@ public function getAttributeValue($name)
431431
/**
432432
* set the attributes for the user
433433
*
434-
* @param UserAttributeEntity $attributes the attributes for the user
434+
* @param ArrayCollection $attributes the attributes for the user
435435
*/
436-
public function setAttributes($attributes)
436+
public function setAttributes(ArrayCollection $attributes)
437437
{
438438
$this->attributes = $attributes;
439439
}
@@ -482,6 +482,11 @@ public function getGroups()
482482
return $this->groups;
483483
}
484484

485+
/**
486+
* set the groups for the user
487+
*
488+
* @param ArrayCollection $groups the groups for the user
489+
*/
485490
public function setGroups(ArrayCollection $groups)
486491
{
487492
$this->groups = $groups;

0 commit comments

Comments
 (0)