zopefoundation / Products.CMFCore

Key framework services for the Zope Content Management Framework (CMF)
Other
6 stars 20 forks source link

Fix indexing queue issue with UNINDEX followed by REINDEX #96

Closed vincentfretin closed 4 years ago

vincentfretin commented 4 years ago

See https://github.com/plone/Products.CMFPlone/issues/2585#issuecomment-653548738 for details. An unindex followed by reindex gives only a unindex. It should really be doing a reindex.

The issue is that

[(UNINDEX, <Image at /Plone/folder/myimage.jpg>, None, None), (REINDEX, <Image at /Plone/folder/myimage.jpg>, [], 1)]

optimize to:

[(UNINDEX, <Image at /Plone/folder/myimage.jpg>, [], 1)]

instead of:

[(REINDEX, <Image at /Plone/folder/myimage.jpg>, [], 1)]

In the indexing.py file the line that is wrong is https://github.com/zopefoundation/Products.CMFCore/blob/55fe79456990b530a00ec3a41005660403421087/Products/CMFCore/indexing.py#L187

in the case of op = UNINDEX (-1) and iop = REINDEX (0), op stays at -1, but it should be at 0. The op += iop works well when you have a symmetry UNINDEX (-1) followed by INDEX (1), it gives REINDEX (0). But here in reality, we may get op = UNINDEX (-1) followed by iop = REINDEX (0)

vincentfretin commented 4 years ago

I updated the issue description with what I understood and committed a fix for this case.

vincentfretin commented 4 years ago

I added a changelog entry. I don't know what is the process here for CMF packages in the zopefoundation organization to merge a PR. Can I merge myself? I signed the zope contributor agreement a long time ago. :-) I see @dataflake did the latest release. Can we please have a 2.4.8 release with this fix to include it in Plone 5.2.2?

dataflake commented 4 years ago

Version 2.4.8 with this fix is now released

vincentfretin commented 4 years ago

That was fast! Thank you.