Skip to content

Commit

Permalink
Merge pull request #5128 from chihiro-adachi/fix-delete-login-member
Browse files Browse the repository at this point in the history
ログインしたメンバーを削除できるように修正
  • Loading branch information
matsuoshi authored Sep 1, 2021
2 parents 45e239e + f6f887b commit 4186b99
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Eccube/Repository/MemberRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ public function delete($Member)
->execute();

$em = $this->getEntityManager();

// ログインしたメンバーの外部参照制約を解除する
// https://github.com/EC-CUBE/ec-cube/issues/5119
$Member->setCreator(null);
$em->flush();

$em->remove($Member);
$em->flush();
}
Expand Down
14 changes: 14 additions & 0 deletions tests/Eccube/Tests/Repository/MemberRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,18 @@ public function testDeleteWithException()
$this->memberRepo->delete($Member1);
$this->fail();
}

/**
* https://github.com/EC-CUBE/ec-cube/issues/5119
*/
public function testDeleteWithException_SelfForeignKey()
{
$Member1 = $this->createMember();
$Member1->setCreator($Member1);
$this->entityManager->flush();

// 削除できることを確認
$this->memberRepo->delete($Member1);
self::assertNull($Member1->getId());
}
}

0 comments on commit 4186b99

Please sign in to comment.