Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHRAS-4059: prod - user account - application cannot be deleted #4503

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,31 @@ public function create($name, $type, $description, $applicationWebsite, User $cr

public function delete(ApiApplication $application)
{
// make sure all apiaccounts linked by apiApplication are also deleted
$accts = $this->om->getRepository('Phraseanet:ApiAccount')->findBy(['application' => $application]);

foreach ($accts as $account) {
// remove ApiOauthCodes before ApiAccount
$oauthCodes = $this->om->getRepository('Phraseanet:ApiOauthCode')->findByAccount($account);
foreach ($oauthCodes as $oauthCode) {
$this->om->remove($oauthCode);
}

$this->om->remove($account);
}

$deliveries = $this->om->getRepository('Phraseanet:WebhookEventDelivery')->findBy(['application' => $application]);

foreach ($deliveries as $delivery) {
$payloads = $this->om->getRepository('Phraseanet:WebhookEventPayload')->findBy(['delivery' => $delivery]);

foreach ($payloads as $payload) {
$this->om->remove($payload);
}

$this->om->remove($delivery);
}

$this->om->remove($application);
$this->om->flush();
}
Expand Down