Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-index subtree on move #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions search/plugins/ezsolr/ezsolr.php
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ public function updateObjectsSection( array $objectIDs, $sectionID )
/**
* Called when a node's visibility is modified.
* Will re-index content identified by $nodeID.
* If the node has children, they will be also re-indexed, but this action is deferred to ezfindexsubtree cronjob.
* If the node has children, they will be also re-indexed, but this action is deferred to ezfindexsubtree cronjob, just like addNodeAssignment() when a node is moved
*
* @todo when Solr supports it: update fields only
*
Expand Down Expand Up @@ -1478,10 +1478,10 @@ public function updateNodeVisibility( $nodeID, $action )
}

/**
* Called when a node assignement is added to an object.
* Called when a node assignment is added to an object.
* Simply re-index for now.
* If the node has children, they will be also re-indexed, but this action is deferred to ezfindexsubtree cronjob, just like updateNodeVisibility()
*
* @todo: defer to cron if there are children involved and re-index these too
* @todo when Solr supports it: update fields only
*
* @param $mainNodeID
Expand All @@ -1494,6 +1494,32 @@ public function updateNodeVisibility( $nodeID, $action )
public function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved )
{
eZContentOperationCollection::registerSearchObject( $objectID, null, $isMoved );

// Re-index the children, if any
if ( $isMoved )
{
// When moving, the node ID list contains only the node being moved
// Ref: eZContentObjectTreeNodeOperations::move()
$nodeID = $nodeAssignmentIDList[0];
$node = eZContentObjectTreeNode::fetch( $nodeID );
$params = array(
'Depth' => 1,
'DepthOperator' => 'eq',
'Limitation' => array(),
'IgnoreVisibility' => true,
);
if ( $node->subTreeCount( $params ) > 0 )
{
$pendingAction = new eZPendingActions(
array(
'action' => self::PENDING_ACTION_INDEX_SUBTREE,
'created' => time(),
'param' => $nodeID
)
);
$pendingAction->store();
}
}
}

/**
Expand Down