Commit 4f58cffa authored by Vincent Pelletier's avatar Vincent Pelletier

EPR5Type.CopySupport: Do not delete activities for deleted document.

These activities may already be running, and deleting them would cause
validation node to violate activity dependencies. For example,
already-running indexation activities will not be waited upon, causing the
unindexation activity spawned below to potentially finish before ongoing
indexation, leading to a catalog persistently inconsistent with object
database.
If these activities are not already running, then CMFActivity will anyway
discard them upon discovering that their execution context does not exist.
And if these activities are failed, then it is a site maintenance issue
(one should not keep failed activities for too long) and must not be a
common case, and not really worthy of handling here.
Also, rework a CMFActivity test checking that activties already-spawned on
a later-deleted context get discarded instead of being executed. Previous
test implementation order was to work around the activity deletion
removed in this commit. The implementation used here is more natural.
parent 7a140455
......@@ -1125,6 +1125,8 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
def testTryUserNotificationOnActivityFailure(self, activity):
message_list = self.portal.MailHost._message_list
del message_list[:]
portal_activities = self.portal.portal_activities
countMessage = portal_activities.countMessage
obj = self.portal.organisation_module.newContent(portal_type='Organisation')
self.tic()
def failingMethod(self): raise ValueError('This method always fails')
......@@ -1140,13 +1142,16 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self.assertIn("Module %s, line %s, in failingMethod" % (
__name__, inspect.getsourcelines(failingMethod)[1]), mail)
self.assertIn("ValueError:", mail)
portal_activities.manageClearActivities()
# MESSAGE_NOT_EXECUTABLE
obj.getParentValue()._delObject(obj.getId())
obj_path = obj.getPath()
obj.activate(activity=activity).failingMethod()
self.commit()
self.assertTrue(obj.hasActivity())
obj.getParentValue()._delObject(obj.getId())
self.commit()
self.assertGreater(countMessage(path=obj_path), 0)
self.tic()
self.assertFalse(obj.hasActivity())
self.assertEqual(countMessage(path=obj_path), 0)
self.assertFalse(message_list)
finally:
del Organisation.failingMethod
......
......@@ -365,8 +365,6 @@ class CopyContainer:
except AttributeError:
pass
else:
# Make sure there is not activity for this object
self.flushActivity(invoke=0)
uid = getattr(self,'uid',None)
if uid is None:
return
......
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