pimcore-dynamic-search icon indicating copy to clipboard operation
pimcore-dynamic-search copied to clipboard

Element EventListener should not trigger re-index in case of draft or versionOnly document updates

Open gadget60 opened this issue 2 years ago • 1 comments

This is not a big deal, but I think we should not trigger document re-indexing on Pre/PostUpdate if not a new version has been published. Particularly it is not necessary in case of Pimcore's "draft auto-save", but also in case of just a new version (without publishing it). In both cases the DocumentEvents::POST_UPDATE event is dispatched, but with some arguments.

Therefore, IMHO we should check something similar to:

$arguments = $event->getArguments();
if ($arguments['saveVersionOnly'] ?? false) {
    return;
}
if ($arguments['isAutoSave'] ?? false) {
    return;
}

...in PimcoreElementListener::onDocumentPostUpdate(): https://github.com/dachcom-digital/pimcore-dynamic-search/blob/b7bfaa16ad7d6935f7c8148758535acb147cc01e/src/DynamicSearchBundle/EventListener/PimcoreElementListener.php#L50

The same applies to objects and their event listeneres too...

gadget60 avatar Nov 25 '22 13:11 gadget60

Hey @gadget60. True, thanks for reporting!

solverat avatar Nov 25 '22 13:11 solverat