Skip to content

Commit adeb87c

Browse files
Fix EZP-23644: add proper handling for hidden nodes in subtree fetches and multiple locations
1 parent 38304f2 commit adeb87c

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

classes/ezfezpsolrquerybuilder.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public function buildSearch( $searchText, $params = array(), $searchTypes = arra
180180
$params['Filter'] = array( $params['Filter'] );
181181
}
182182

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

184185

185186
$filterQuery = array();
@@ -191,7 +192,7 @@ public function buildSearch( $searchText, $params = array(), $searchTypes = arra
191192
$subtreeQueryParts = array();
192193
foreach ( $subtrees as $subtreeNodeID )
193194
{
194-
$subtreeQueryParts[] = eZSolr::getMetaFieldName( 'path' ) . ':' . $subtreeNodeID;
195+
$subtreeQueryParts[] = $pathFieldName . ':' . $subtreeNodeID;
195196
}
196197

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

1537+
$pathFieldName = $ignoreVisibility ? eZSolr::getMetaFieldName( 'path' ) : eZSolr::getMetaFieldName( 'visible_path' );
1538+
15361539
if ( is_array( $limitation ) )
15371540
{
15381541
if ( empty( $limitation ) )
@@ -1606,7 +1609,7 @@ protected function policyLimitationFilterQuery( $limitation = null, $ignoreVisib
16061609
$pathArray = explode( '/', $pathString );
16071610
// we only take the last node ID in the path identification string
16081611
$subtreeNodeID = array_pop( $pathArray );
1609-
$policyLimitationsOnLocations[] = eZSolr::getMetaFieldName( 'path' ) . ':' . $subtreeNodeID;
1612+
$policyLimitationsOnLocations[] = $pathFieldName . ':' . $subtreeNodeID;
16101613
if ( isset( $this->searchPluginInstance->postSearchProcessingData['subtree_limitations'] ) )
16111614
$this->searchPluginInstance->postSearchProcessingData['subtree_limitations'][] = $subtreeNodeID;
16121615
else

java/solr/ezp-default/conf/schema.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149

150150
<!-- A Trie based date field for faster date range queries and date faceting. -->
151151
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>
152-
152+
153153
<!--
154154
Note:
155155
These should only be used for compatibility with existing indexes (created with older Solr versions)
@@ -564,6 +564,11 @@
564564
<field name="meta_is_hidden_b" type="boolean" indexed="true" stored="true" multiValued="true"/>
565565
<field name="meta_is_invisible_b" type="boolean" indexed="true" stored="true" multiValued="true"/>
566566
<field name="meta_priority_si" type="sint" indexed="true" stored="true" multiValued="true"/>
567+
<!-- denormalised fields for hidden and visible path elements -->
568+
<field name="meta_visible_path_si" type="sint" indexed="true" stored="true" multiValued="true"/> <!-- Visible Location path IDs -->
569+
<field name="meta_visible_path_string_ms" type="mstring" indexed="true" stored="true" multiValued="true"/> <!-- Visible Location path string -->
570+
<field name="meta_hidden_path_si" type="sint" indexed="true" stored="true" multiValued="true"/> <!-- Hidden Location path IDs -->
571+
<field name="meta_hidden_path_string_ms" type="mstring" indexed="true" stored="true" multiValued="true"/> <!-- Hidden Location path string -->
567572

568573
<!-- Here, default is used to create a "timestamp" field indicating
569574
When each document was indexed.

search/plugins/ezsolr/ezsolr.php

+26-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ static function getMetaAttributeType( $name, $context = 'search' )
124124
'owner_name' => 'text',
125125
'owner_group_id' => 'sint',
126126
'path' => 'sint',
127-
'object_states' => 'sint'),
127+
'object_states' => 'sint',
128+
'visible_path' => 'sint',
129+
'hidden_path' => 'sint',
130+
'visible_path_string' => 'mstring',
131+
'hidden_path_string' => 'mstring' ),
128132
self::metaAttributes(),
129133
self::nodeAttributes() ),
130134
'facet' => array(
@@ -464,6 +468,11 @@ function addObject( $contentObject, $commit = true, $commitWithin = 0, $softComm
464468
$mainNodeID = $mainNode->attribute( 'node_id' );
465469
// initialize array of parent node path ids, needed for multivalued path field and subtree filters
466470
$nodePathArray = array();
471+
// eZ Find 5.4+ expanding on nodePathArray, collect them in different visibility arrays
472+
$invisibleNodePathArray = array();
473+
$visibleNodePathArray = array();
474+
$invisibleNodePathString = array();
475+
$visibleNodePathString = array();
467476

468477
//included in $nodePathArray
469478
//$pathArray = $mainNode->attribute( 'path_array' );
@@ -484,6 +493,16 @@ function addObject( $contentObject, $commit = true, $commitWithin = 0, $softComm
484493
'fieldType' => $fieldType );
485494
}
486495
$nodePathArray[] = $contentNode->attribute( 'path_array' );
496+
if ( $contentNode->attribute( 'is_hidden' ) || $contentNode->attribute( 'is_invisible' ) )
497+
{
498+
$invisibleNodePathArray = array_merge( $invisibleNodePathArray, $contentNode->attribute( 'path_array' ) );
499+
$invisibleNodePathString[]= $contentNode->attribute( 'path_string' );
500+
}
501+
else
502+
{
503+
$visibleNodePathArray = array_merge( $visibleNodePathArray, $contentNode->attribute( 'path_array' ) );
504+
$visibleNodePathString[] = $contentNode->attribute( 'path_string' );
505+
}
487506

488507
}
489508

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

629648
}
649+
// Since eZ Find 5.4
650+
651+
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'visible_path' ), $visibleNodePathArray );
652+
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'visible_path_string' ), $visibleNodePathString );
653+
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'hidden_path' ), $invisibleNodePathArray );
654+
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'hidden_path_string' ), $invisibleNodePathString );
630655

631656
eZContentObject::recursionProtectionStart();
632657

0 commit comments

Comments
 (0)