From d1ed2aaada4b3e36c2a91539832394407445a7cf Mon Sep 17 00:00:00 2001 From: vnivuahc <25658540+vnivuahc@users.noreply.github.com> Date: Thu, 28 Jun 2018 15:03:42 +0200 Subject: [PATCH] Update index when adding/removing node assignment (#1353) In the back-end, when you add a new location to an existing content, or remove one, the search index is not updated. --- .../content/ezcontentoperationcollection.php | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/kernel/content/ezcontentoperationcollection.php b/kernel/content/ezcontentoperationcollection.php index f1432aedc08..373d99371dd 100644 --- a/kernel/content/ezcontentoperationcollection.php +++ b/kernel/content/ezcontentoperationcollection.php @@ -823,6 +823,11 @@ static public function addAssignment( $nodeID, $objectID, $selectedNodeIDArray ) eZContentCacheManager::clearContentCacheIfNeeded( $objectID ); + if ( !eZSearch::getEngine() instanceof eZSearchEngine ) + { + eZContentOperationCollection::registerSearchObject( $objectID ); + } + return array( 'status' => true ); } @@ -902,6 +907,13 @@ static public function removeNodes( array $removeNodeIdList ) { eZUser::purgeUserCacheByUserId( $object->attribute( 'id' ) ); } + + // Give other search engines that the default one a chance to reindex + // when removing locations. + if ( !eZSearch::getEngine() instanceof eZSearchEngine ) + { + eZContentOperationCollection::registerSearchObject( $objectId ); + } } // Triggering content/cache filter for Http cache purge @@ -1125,6 +1137,10 @@ static public function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() // clear cache for new placement. eZContentCacheManager::clearContentCacheIfNeeded( $objectID ); + if ( !eZSearch::getEngine() instanceof eZSearchEngine ) + { + eZContentOperationCollection::registerSearchObject( $objectID ); + } eZSearch::swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() ); @@ -1256,11 +1272,14 @@ static public function updatePriority( $parentNodeID, $priorityArray = array(), * * @return array An array with operation status, always true */ - static public function updateMainAssignment( $mainAssignmentID, $ObjectID, $mainAssignmentParentID ) + static public function updateMainAssignment( $mainAssignmentID, $objectID, $mainAssignmentParentID ) { - eZContentObjectTreeNode::updateMainNodeID( $mainAssignmentID, $ObjectID, false, $mainAssignmentParentID ); - eZContentCacheManager::clearContentCacheIfNeeded( $ObjectID ); - eZContentOperationCollection::registerSearchObject( $ObjectID ); + eZContentObjectTreeNode::updateMainNodeID( $mainAssignmentID, $objectID, false, $mainAssignmentParentID ); + eZContentCacheManager::clearContentCacheIfNeeded( $objectID ); + if ( !eZSearch::getEngine() instanceof eZSearchEngine ) + { + eZContentOperationCollection::registerSearchObject( $objectID ); + } return array( 'status' => true ); }