From 39a7aaaa9eed046c1fb2eb2ea33e1ee0c468bbfd Mon Sep 17 00:00:00 2001 From: Valentin Dumitru <1492705+valipod@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:27:03 +0300 Subject: [PATCH 1/3] Avoid full object reindex on security reindex Add `update_metadata=0` parameter to reindexObjectSecurity to avoid a full reindex instead of just `allowedRolesAndUsers`. --- src/Products/CMFCore/CMFCatalogAware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Products/CMFCore/CMFCatalogAware.py b/src/Products/CMFCore/CMFCatalogAware.py index 502161f..2adc607 100644 --- a/src/Products/CMFCore/CMFCatalogAware.py +++ b/src/Products/CMFCore/CMFCatalogAware.py @@ -125,7 +125,7 @@ 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() From 86c2e770f698f808546f4ffa0b3ffd3ebbc09c79 Mon Sep 17 00:00:00 2001 From: Valentin Dumitru <1492705+valipod@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:35:46 +0300 Subject: [PATCH 2/3] Update CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 4dab6fe..858a776 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) From cc5c8ad2f531430e6eb4d1681783429ec7670ad1 Mon Sep 17 00:00:00 2001 From: Valentin Dumitru Date: Tue, 20 Aug 2024 16:19:41 +0300 Subject: [PATCH 3/3] Fix test related to reindexObjectSecurity fix lint error --- src/Products/CMFCore/CMFCatalogAware.py | 3 ++- src/Products/CMFCore/tests/test_CMFCatalogAware.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Products/CMFCore/CMFCatalogAware.py b/src/Products/CMFCore/CMFCatalogAware.py index 2adc607..93b85be 100644 --- a/src/Products/CMFCore/CMFCatalogAware.py +++ b/src/Products/CMFCore/CMFCatalogAware.py @@ -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, update_metadata=0) + ob.reindexObject(idxs=self._cmf_security_indexes, + update_metadata=0) if s is None: ob._p_deactivate() diff --git a/src/Products/CMFCore/tests/test_CMFCatalogAware.py b/src/Products/CMFCore/tests/test_CMFCatalogAware.py index a3ba09a..00fb5ce 100644 --- a/src/Products/CMFCore/tests/test_CMFCatalogAware.py +++ b/src/Products/CMFCore/tests/test_CMFCatalogAware.py @@ -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) @@ -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