From c9af39b5b3aff06f25c67fbf6ff7315a4c2fc19b Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek <38975612+mateuszbieniek@users.noreply.github.com> Date: Wed, 22 Aug 2018 15:04:59 +0200 Subject: [PATCH] EZP-29379: Option to skip search engine indexing inside eZContentOperationCollection::updateSection (#1381) Followup for #1378 (0afc0aead1bc58d3c3e4a8b811882447ff1fd258) --- kernel/classes/ezcontentobjecttreenode.php | 7 +++++-- kernel/classes/ezsection.php | 2 +- kernel/content/ezcontentoperationcollection.php | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/classes/ezcontentobjecttreenode.php b/kernel/classes/ezcontentobjecttreenode.php index 683ba581788..718d36255c0 100644 --- a/kernel/classes/ezcontentobjecttreenode.php +++ b/kernel/classes/ezcontentobjecttreenode.php @@ -2796,7 +2796,7 @@ static function sortArrayBySortFieldAndSortOrder( $sortField, $sortOrder ) \note Transaction unsafe. If you call several transaction unsafe methods you must enclose the calls within a db transaction; thus within db->begin and db->commit. */ - static function assignSectionToSubTree( $nodeID, $sectionID, $oldSectionID = false ) + static function assignSectionToSubTree( $nodeID, $sectionID, $oldSectionID = false, $updateSearchIndexes = true ) { $db = eZDB::instance(); $node = eZContentObjectTreeNode::fetch( $nodeID ); @@ -2827,7 +2827,10 @@ static function assignSectionToSubTree( $nodeID, $sectionID, $oldSectionID = fal foreach ( array_chunk( $objectSimpleIDArray, 100 ) as $pagedObjectIDs ) { $db->query( "UPDATE ezcontentobject SET section_id='$sectionID' WHERE $filterPart " . $db->generateSQLINStatement( $pagedObjectIDs, 'id', false, true, 'int' ) ); - eZSearch::updateObjectsSection( $pagedObjectIDs, $sectionID ); + if ( $updateSearchIndexes ) + { + eZSearch::updateObjectsSection( $pagedObjectIDs, $sectionID ); + } } $db->commit(); diff --git a/kernel/classes/ezsection.php b/kernel/classes/ezsection.php index 5ac57f5a595..0fe2c669667 100644 --- a/kernel/classes/ezsection.php +++ b/kernel/classes/ezsection.php @@ -240,7 +240,7 @@ public function applyTo( eZContentObject $object ) { foreach ( $assignedNodes as $node ) { - eZContentOperationCollection::updateSection( $node->attribute( "node_id" ), $sectionID ); + eZContentOperationCollection::updateSection( $node->attribute( "node_id" ), $sectionID, false ); } } } diff --git a/kernel/content/ezcontentoperationcollection.php b/kernel/content/ezcontentoperationcollection.php index 373d99371dd..42fb2906ae1 100644 --- a/kernel/content/ezcontentoperationcollection.php +++ b/kernel/content/ezcontentoperationcollection.php @@ -1152,12 +1152,13 @@ static public function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() * * @param int $nodeID * @param int $selectedSectionID + * @param bool $updateSearchIndexes * - * @return array An array with operation status, always true + * @return void */ - static public function updateSection( $nodeID, $selectedSectionID ) + static public function updateSection( $nodeID, $selectedSectionID, $updateSearchIndexes = true ) { - eZContentObjectTreeNode::assignSectionToSubTree( $nodeID, $selectedSectionID ); + eZContentObjectTreeNode::assignSectionToSubTree( $nodeID, $selectedSectionID, false, $updateSearchIndexes ); } /**