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

Fix EZP-23644: add proper handling for hidden nodes in subtree fetches a... #181

Merged
merged 1 commit into from
Mar 23, 2015
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions classes/ezfezpsolrquerybuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public function buildSearch( $searchText, $params = array(), $searchTypes = arra
$params['Filter'] = array( $params['Filter'] );
}

$pathFieldName = eZSolr::getMetaFieldName( $ignoreVisibility ? 'path' : 'visible_path' );


$filterQuery = array();
Expand All @@ -191,7 +192,7 @@ public function buildSearch( $searchText, $params = array(), $searchTypes = arra
$subtreeQueryParts = array();
foreach ( $subtrees as $subtreeNodeID )
{
$subtreeQueryParts[] = eZSolr::getMetaFieldName( 'path' ) . ':' . $subtreeNodeID;
$subtreeQueryParts[] = $pathFieldName . ':' . $subtreeNodeID;
}

$filterQuery[] = implode( ' OR ', $subtreeQueryParts );
Expand Down Expand Up @@ -1533,6 +1534,8 @@ protected function policyLimitationFilterQuery( $limitation = null, $ignoreVisib
$filterQuery = false;
$policies = array();

$pathFieldName = $ignoreVisibility ? eZSolr::getMetaFieldName( 'path' ) : eZSolr::getMetaFieldName( 'visible_path' );

if ( is_array( $limitation ) )
{
if ( empty( $limitation ) )
Expand Down Expand Up @@ -1606,7 +1609,7 @@ protected function policyLimitationFilterQuery( $limitation = null, $ignoreVisib
$pathArray = explode( '/', $pathString );
// we only take the last node ID in the path identification string
$subtreeNodeID = array_pop( $pathArray );
$policyLimitationsOnLocations[] = eZSolr::getMetaFieldName( 'path' ) . ':' . $subtreeNodeID;
$policyLimitationsOnLocations[] = $pathFieldName . ':' . $subtreeNodeID;
if ( isset( $this->searchPluginInstance->postSearchProcessingData['subtree_limitations'] ) )
$this->searchPluginInstance->postSearchProcessingData['subtree_limitations'][] = $subtreeNodeID;
else
Expand Down
7 changes: 6 additions & 1 deletion java/solr/ezp-default/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@

<!-- A Trie based date field for faster date range queries and date faceting. -->
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>

<!--
Note:
These should only be used for compatibility with existing indexes (created with older Solr versions)
Expand Down Expand Up @@ -564,6 +564,11 @@
<field name="meta_is_hidden_b" type="boolean" indexed="true" stored="true" multiValued="true"/>
<field name="meta_is_invisible_b" type="boolean" indexed="true" stored="true" multiValued="true"/>
<field name="meta_priority_si" type="sint" indexed="true" stored="true" multiValued="true"/>
<!-- denormalised fields for hidden and visible path elements -->
<field name="meta_visible_path_si" type="sint" indexed="true" stored="true" multiValued="true"/> <!-- Visible Location path IDs -->
<field name="meta_visible_path_string_ms" type="mstring" indexed="true" stored="true" multiValued="true"/> <!-- Visible Location path string -->
<field name="meta_hidden_path_si" type="sint" indexed="true" stored="true" multiValued="true"/> <!-- Hidden Location path IDs -->
<field name="meta_hidden_path_string_ms" type="mstring" indexed="true" stored="true" multiValued="true"/> <!-- Hidden Location path string -->

<!-- Here, default is used to create a "timestamp" field indicating
When each document was indexed.
Expand Down
27 changes: 26 additions & 1 deletion search/plugins/ezsolr/ezsolr.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ static function getMetaAttributeType( $name, $context = 'search' )
'owner_name' => 'text',
'owner_group_id' => 'sint',
'path' => 'sint',
'object_states' => 'sint'),
'object_states' => 'sint',
'visible_path' => 'sint',
'hidden_path' => 'sint',
'visible_path_string' => 'mstring',
'hidden_path_string' => 'mstring' ),
self::metaAttributes(),
self::nodeAttributes() ),
'facet' => array(
Expand Down Expand Up @@ -464,6 +468,11 @@ function addObject( $contentObject, $commit = true, $commitWithin = 0, $softComm
$mainNodeID = $mainNode->attribute( 'node_id' );
// initialize array of parent node path ids, needed for multivalued path field and subtree filters
$nodePathArray = array();
// eZ Find 5.4+ expanding on nodePathArray, collect them in different visibility arrays
$invisibleNodePathArray = array();
$visibleNodePathArray = array();
$invisibleNodePathString = array();
$visibleNodePathString = array();

//included in $nodePathArray
//$pathArray = $mainNode->attribute( 'path_array' );
Expand All @@ -484,6 +493,16 @@ function addObject( $contentObject, $commit = true, $commitWithin = 0, $softComm
'fieldType' => $fieldType );
}
$nodePathArray[] = $contentNode->attribute( 'path_array' );
if ( $contentNode->attribute( 'is_hidden' ) || $contentNode->attribute( 'is_invisible' ) )
{
$invisibleNodePathArray = array_merge( $invisibleNodePathArray, $contentNode->attribute( 'path_array' ) );
$invisibleNodePathString[]= $contentNode->attribute( 'path_string' );
}
else
{
$visibleNodePathArray = array_merge( $visibleNodePathArray, $contentNode->attribute( 'path_array' ) );
$visibleNodePathString[] = $contentNode->attribute( 'path_string' );
}

}

Expand Down Expand Up @@ -627,6 +646,12 @@ function addObject( $contentObject, $commit = true, $commitWithin = 0, $softComm
$doc->addField( 'meta_main_path_element_' . $key . '_si', $pathNodeID );

}
// Since eZ Find 5.4

$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'visible_path' ), $visibleNodePathArray );
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'visible_path_string' ), $visibleNodePathString );
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'hidden_path' ), $invisibleNodePathArray );
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'hidden_path_string' ), $invisibleNodePathString );

eZContentObject::recursionProtectionStart();

Expand Down