Skip to content

Commit

Permalink
Avoid full object reindex on security reindex (#143)
Browse files Browse the repository at this point in the history
* Avoid full object reindex on security reindex

Add `update_metadata=0` parameter to reindexObjectSecurity to avoid a full reindex instead of just `allowedRolesAndUsers`.

* Update CHANGES.rst

* Fix test related to reindexObjectSecurity
fix lint error

---------

Co-authored-by: Dieter Maurer <d-maurer@users.noreply.github.com>
  • Loading branch information
valipod and d-maurer authored Sep 9, 2024
1 parent de9c29e commit a054d06
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
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),
])
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)])
self.assertFalse(foo.notified)
self.assertFalse(missing.notified)
self.assertEqual(len(self.logged), 1) # logging because no raise
Expand Down

0 comments on commit a054d06

Please sign in to comment.