Commit f786f2f6 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[hooks] Propery handle case of data-object deletion in hook synchronizing file_category changes

Since the operation may be triggered by deletion of the relation, it may be
unadvertanly called by cascade when the data-object is being deleted.
parent 919faf33df18
......@@ -473,6 +473,8 @@ class SyncFileCategoryOp(hook.DataOperationMixIn, hook.LateOperation):
def precommit_event(self):
for bdo_eid in self.get_data():
if self.cnx.deleted_in_transaction(bdo_eid):
bdo = self.cnx.entity_from_eid(bdo_eid)
if not bdo.container:
# we may have to clear the container cache if the parent has
......@@ -275,6 +275,11 @@ class DispatchFileCategoryTC(CubicWebTC):
['application/msword', 'application/pdf'],
['fmt/37', 'fmt/38', 'fmt/14'])
# ensure deleting the data object doesn't raise an exception because
# of erroneous hook
def test_join(self):
with self.admin_access.cnx() as cnx:
transfer = cnx.entity_from_eid(self.transfer_eid)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment