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

Avoid full object reindex on security reindex #143

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Products.CMFCore Changelog
----------------

- Drop support for Python 3.7.
- Fix reindexObjectSecurity to avoid a full reindex of affected objects


3.5 (2024-03-23)
Expand Down
3 changes: 2 additions & 1 deletion src/Products/CMFCore/CMFCatalogAware.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def reindexObjectSecurity(self, skip_self=False):
'catalog', brain_path)
continue
s = getattr(ob, '_p_changed', 0)
ob.reindexObject(idxs=self._cmf_security_indexes)
ob.reindexObject(idxs=self._cmf_security_indexes,
update_metadata=0)
if s is None:
ob._p_deactivate()

Expand Down
8 changes: 4 additions & 4 deletions src/Products/CMFCore/tests/test_CMFCatalogAware.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ def test_reindexObjectSecurity(self):
foo.reindexObjectSecurity()
log = sorted(cat.log)
self.assertEqual(log, [
'reindex /site/foo %s 1' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo/bar %s 1' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo/hop %s 1' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo %s 0' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo/bar %s 0' % str(CMF_SECURITY_INDEXES),
'reindex /site/foo/hop %s 0' % str(CMF_SECURITY_INDEXES),
d-maurer marked this conversation as resolved.
Show resolved Hide resolved
])
self.assertFalse(foo.notified)
self.assertFalse(bar.notified)
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_reindexObjectSecurity_missing_noraise(self):
foo.reindexObjectSecurity()
self.assertEqual(
cat.log,
['reindex /site/foo %s 1' % str(CMF_SECURITY_INDEXES)])
['reindex /site/foo %s 0' % str(CMF_SECURITY_INDEXES)])
d-maurer marked this conversation as resolved.
Show resolved Hide resolved
self.assertFalse(foo.notified)
self.assertFalse(missing.notified)
self.assertEqual(len(self.logged), 1) # logging because no raise
Expand Down