pimcore-dynamic-search
pimcore-dynamic-search copied to clipboard
Element EventListener should not trigger re-index in case of draft or versionOnly document updates
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...
Hey @gadget60. True, thanks for reporting!