-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix EZP-23681: Delayed indexing of subtree on move
- Loading branch information
1 parent
79ed304
commit 9a15f89
Showing
5 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
while( true ) | ||
{ | ||
$entries = $db->arrayQuery( | ||
"SELECT param FROM ezpending_actions WHERE action = 'index_object' GROUP BY param ORDER BY min(created)", | ||
"SELECT param, action FROM ezpending_actions WHERE action = 'index_object' OR action = 'index_moved_node' GROUP BY param ORDER BY min(created)", | ||
array( 'limit' => $limit, 'offset' => $offset ) | ||
); | ||
|
||
|
@@ -38,6 +38,7 @@ | |
foreach ( $entries as $entry ) | ||
{ | ||
$objectID = (int)$entry['param']; | ||
$action = $entry['action']; | ||
|
||
$cli->output( "\tIndexing object ID #$objectID" ); | ||
$db->begin(); | ||
|
@@ -49,12 +50,64 @@ | |
{ | ||
$searchEngine->removeObject( $object, false ); | ||
} | ||
|
||
$removeFromPendingActions = $searchEngine->addObject( $object, false ); | ||
|
||
// When moving content (and only, because of performances), reindex the subtree | ||
if ( $action == 'index_moved_node' ) | ||
{ | ||
$nodeId = $object->attribute( 'main_node_id' ); | ||
$node = eZContentObjectTreeNode::fetch( $nodeId ); | ||
|
||
if ( !( $node instanceof eZContentObjectTreeNode ) ) | ||
{ | ||
$cli->error( "An error occured while trying fetching node $nodeId" ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yannickroger
Author
Contributor
|
||
} | ||
|
||
$offset = 0; | ||
$limit = 50; | ||
|
||
$params = array( 'Limitation' => array(), 'MainNodeOnly' => true ); | ||
|
||
$subtreeCount = $node->subTreeCount( $params ); | ||
|
||
while ( $offset < $subtreeCount ) | ||
{ | ||
$subTree = $node->subTree( | ||
array_merge( | ||
$params, | ||
array( 'Offset' => $offset, 'Limit' => $limit, 'SortBy' => array() ) | ||
) | ||
); | ||
|
||
if ( !empty( $subTree ) ) | ||
{ | ||
foreach ( $subTree as $innerNode ) | ||
{ | ||
/** @var $innerNode eZContentObjectTreeNode */ | ||
$childObject = $innerNode->attribute( 'object' ); | ||
if ( !$childObject ) | ||
{ | ||
continue; | ||
} | ||
|
||
$searchEngine->addObject( $childObject, false ); | ||
} | ||
} | ||
|
||
$offset += $limit; | ||
|
||
if ( $offset >= $subtreeCount ) | ||
{ | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if ( $removeFromPendingActions ) | ||
{ | ||
$db->query( "DELETE FROM ezpending_actions WHERE action = 'index_object' AND param = '$objectID'" ); | ||
$db->query( "DELETE FROM ezpending_actions WHERE action = '$action' AND param = '$objectID'" ); | ||
} | ||
else | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 9a15f89
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about content hide operations are they safe?
continue
?