Commit 96031946 authored by Jérome Perrin's avatar Jérome Perrin

Folder: fix checkConsistency on folder containing non erp5 objects

contentValues() nowadays return also non ERP5-ish objects such as python
scripts , OFS.File etc. Because of that, if an ERP5 Folder contained a
non ERP5 object, which does not have fixConsistency or checkConsistency
methods, Folder.checkConsistency was causing an infinite loop because it
was acquiring checkConsistency method from self.
parent 3b5d36c0
No related merge requests found
......@@ -1616,6 +1616,32 @@ class TestConstraint(PropertySheetTestCase):
document.checkConsistency()
self.assertEqual("Fooa", document.getTitle())
def test_checkConsistency_is_recursive(self):
self._addProperty(
self.object_content_portal_type,
self.id(),
commit=True,
property_id="title_constraint",
portal_type='Attribute Equality Constraint',
constraint_attribute_name = 'title',
constraint_attribute_value = 'string:a',
)
obj = self._makeOne()
self.assertEqual([], obj.checkConsistency())
self.assertEqual([], obj.fixConsistency())
obj.newContent(portal_type=self.object_content_portal_type)
self.assertEqual(1, len(obj.checkConsistency()))
self.assertEqual(1, len(obj.fixConsistency()))
# non ERP5 objects are ignored
from OFS.Image import manage_addFile
manage_addFile(obj, self.id(),)
self.assertEqual(1, len(obj.checkConsistency()))
self.assertEqual(1, len(obj.fixConsistency()))
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestConstraint))
......
......@@ -1465,11 +1465,11 @@ class Folder(FolderMixIn, CopyContainer, ObjectManager, Base, OFSFolder2, CMFBTr
# of this name implement consistency checking on object
continue
if fixit:
extra_errors = obj.fixConsistency(filter=filter, **kw)
if hasattr(aq_base(obj), 'fixConsistency'):
error_list.extend(obj.fixConsistency(filter=filter, **kw))
else:
extra_errors = obj.checkConsistency(filter=filter, **kw)
if len(extra_errors) > 0:
error_list += extra_errors
if hasattr(aq_base(obj), 'checkConsistency'):
error_list.extend(obj.checkConsistency(filter=filter, **kw))
# We should also return an error if any
return error_list
......
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