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

Commit 17590c2

Browse files
committed
fixed #3726
1 parent 45420f2 commit 17590c2

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
@@ -496,9 +496,9 @@ public function getAttributeValue($name)
496496
/**
497497
* set the attributes for the user
498498
*
499-
* @param UserAttributeEntity $attributes the attributes for the user
499+
* @param ArrayCollection $attributes the attributes for the user
500500
*/
501-
public function setAttributes($attributes)
501+
public function setAttributes(ArrayCollection $attributes)
502502
{
503503
$this->attributes = $attributes;
504504
}
@@ -547,6 +547,11 @@ public function getGroups()
547547
return $this->groups;
548548
}
549549

550+
/**
551+
* set the groups for the user
552+
*
553+
* @param ArrayCollection $groups the groups for the user
554+
*/
550555
public function setGroups(ArrayCollection $groups)
551556
{
552557
$this->groups = $groups;

0 commit comments

Comments
 (0)