-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Delete Event isn't triggered in Batch delete #6550
Comments
Please ensure that registered extension SonataAdminBundle/src/Event/AdminEventExtension.php Lines 112 to 118 in be653e2
Or use doctrine remove events |
You're right, The deleteAction is calling What did you have in mind to fix this ? |
@VincentLanglet |
Then we would stop to use the modelManager batchDelete method https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Controller/CRUDController.php#L177 I assume the bacthDelete method was a delete method optimized so I'm not sure it's a good idea to use multiple times the Best would be to find another solution. cc @sonata-project/contributors |
I agree that removing objects in a batch operation should behave like any single remove operation (including the extension logic, etc). |
What about this? public function batchActionDelete(ProxyQueryInterface $query)
{
$this->admin->checkAccess('batchDelete');
$modelManager = $this->admin->getModelManager();
try {
foreach($modelManager->getObjectsToBatchDeleting($query) as $object) {
$this->admin->delete($object);
}
$this->addFlash(
'sonata_flash_success',
$this->trans('flash_batch_delete_success', [], 'SonataAdminBundle')
);
} catch (ModelManagerException $e) {
$this->handleModelManagerException($e);
$this->addFlash(
'sonata_flash_error',
$this->trans('flash_batch_delete_error', [], 'SonataAdminBundle')
);
}
return $this->redirectToList();
} |
What you're proposing doesn't seem to be a batch operation, since |
This is exactly what we need! |
@phansys says any time ago:
And now you say other solve. |
AFAIK, we need to trigger the events associated to the remove operation for the removed objects, not commit the transaction for each single object. |
Run deleting transactions its task of |
I agree, and I'm not going against that premise. |
No difference if we run In my example getObjectsToBatchDeleting($query) has iterator & clear manager logic every 20 iterations. Im would like take attention that if call postRemove when deletion transation not executed - wrong behavior I, as an ordinary user, expect that deleting many objects is equivalent to deleting each one separately. |
You can edit a message instead of posting 6 consecutive messages.
If we decide to lose the benefit of a batch operation, we can just do
And we could deprecate the BatchDelete method from ModelManagerInterface. |
In case we keep the benefit of the batch operation, this is an example about what I've mentioned before: https://3v4l.org/HjjWH. |
Benefit in run flushing and crearing every 20 iterations? Hmm. You know that is useless? Database lock query results in your operation memory in any way? Calling Same problem here with exporting: Im see one really benefit in clearing.
Im would like see that |
I won't say it's useless when it's in the doctrine documentation: https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/batch-processing.html#bulk-deletes |
Idea: may be batch operations should trigger other event, like "batchDelete" where you receive all ids, and then decice what to do with them. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This adds a preBatchAction() method to the AbstractAdminExtension and AdminExtensionInterface (BC). This enables the AdminEventExtension to dispatch a BatchActionEvent of type pre_batch_action. Both the extension and the event provide points to hook into within your own code, just like this is possible for pre/post persist/update/delete. Fixes sonata-project#7516 "Implement an event for batch actions" Relates to sonata-project#6550 "Delete Event isn't triggered in Batch delete"
This adds a preBatchAction() method to the AbstractAdminExtension and AdminExtensionInterface (BC). This enables the AdminEventExtension to dispatch a BatchActionEvent of type pre_batch_action. Both the extension and the event provide points to hook into within your own code, just like this is possible for pre/post persist/update/delete. Fixes sonata-project#7516 "Implement an event for batch actions" Relates to sonata-project#6550 "Delete Event isn't triggered in Batch delete"
This adds a preBatchAction() method to the AbstractAdminExtension and AdminExtensionInterface (BC). This enables the AdminEventExtension to dispatch a BatchActionEvent of type pre_batch_action. Both the extension and the event provide points to hook into within your own code, just like this is possible for pre/post persist/update/delete. Fixes sonata-project#7516 "Implement an event for batch actions" Relates to sonata-project#6550 "Delete Event isn't triggered in Batch delete"
This adds a preBatchAction() method to the AbstractAdminExtension and AdminExtensionInterface (BC). This enables the AdminEventExtension to dispatch a BatchActionEvent of type pre_batch_action. Both the extension and the event provide points to hook into within your own code, just like this is possible for pre/post persist/update/delete. Fixes sonata-project#7516 "Implement an event for batch actions" Relates to sonata-project#6550 "Delete Event isn't triggered in Batch delete"
This adds a preBatchAction() method to the AbstractAdminExtension and AdminExtensionInterface (BC). This enables the AdminEventExtension to dispatch a BatchActionEvent of type pre_batch_action. Both the extension and the event provide points to hook into within your own code, just like this is possible for pre/post persist/update/delete. Fixes sonata-project#7516 "Implement an event for batch actions" Relates to sonata-project#6550 "Delete Event isn't triggered in Batch delete"
This adds a preBatchAction() method to the AbstractAdminExtension and AdminExtensionInterface (BC). This enables the AdminEventExtension to dispatch a BatchActionEvent of type pre_batch_action. Both the extension and the event provide points to hook into within your own code, just like this is possible for pre/post persist/update/delete. Fixes sonata-project#7516 "Implement an event for batch actions" Relates to sonata-project#6550 "Delete Event isn't triggered in Batch delete"
This adds a preBatchAction() method to the AbstractAdminExtension and AdminExtensionInterface (BC). This enables the AdminEventExtension to dispatch a BatchActionEvent of type pre_batch_action. Both the extension and the event provide points to hook into within your own code, just like this is possible for pre/post persist/update/delete. Fixes sonata-project#7516 "Implement an event for batch actions" Relates to sonata-project#6550 "Delete Event isn't triggered in Batch delete"
This adds a preBatchAction() method to the AbstractAdminExtension and AdminExtensionInterface (BC). This enables the AdminEventExtension to dispatch a BatchActionEvent of type pre_batch_action. Both the extension and the event provide points to hook into within your own code, just like this is possible for pre/post persist/update/delete. Fixes sonata-project#7516 "Implement an event for batch actions" Relates to sonata-project#6550 "Delete Event isn't triggered in Batch delete"
This adds a preBatchAction() method to the AbstractAdminExtension and AdminExtensionInterface (BC). This enables the AdminEventExtension to dispatch a BatchActionEvent of type pre_batch_action. Both the extension and the event provide points to hook into within your own code, just like this is possible for pre/post persist/update/delete. Fixes #7516 "Implement an event for batch actions" Relates to #6550 "Delete Event isn't triggered in Batch delete"
Environment
PHP FPM Image with separated NGINX
Sonata packages
Symfony packages
PHP version
Subject
When a batch delete is executed, there is no event fired for the Document.
Steps to reproduce
Register an delete Event
Expected results
The
onImageDelete
function should be executed - even in Batch mode.Actual results
Only the Document is deleted, but without executing the registered Event handler.
I can create a pull request with a fix, if you want.
The text was updated successfully, but these errors were encountered: