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

Fixed #1225 #1226

Merged
merged 10 commits into from
Jun 19, 2024
Merged

Fixed #1225 #1226

merged 10 commits into from
Jun 19, 2024

Conversation

prabhat-webkul
Copy link
Collaborator

fixed for #1225

on organization delete, persons are removed but can't be saved again.

removed attribute values of persons on organization delete.

@komal-sh-27
Copy link

I have checked this PR and it is working fine.

{
$organization = $this->model->findOrFail($id);

$organization->persons->each->delete();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause DDOS. Use single query to delete all the persons.

$organization->persons()->delete();

@suraj-webkul suraj-webkul self-assigned this Jun 13, 2024

$organization->persons()->delete();

$this->attributeValueRepository->deleteWhere([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will remove all other entities also. Add entity_type as well.

Comment on lines 83 to 90
$organization->persons()->delete();

$this->attributeValueRepository->deleteWhere([
'entity_id' => $id,
'entity_type' => 'organizations',
]);

$organization->delete($id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap this multiple deletion in transaction to make it atomic.

@devansh-webkul devansh-webkul merged commit 8f35494 into krayin:master Jun 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants