Skip to content

Commit

Permalink
Fixed EZP-19673: search results contain link to hidden nodes
Browse files Browse the repository at this point in the history
Make sure the main node is returned if the user can read it and if it
matches the visibility requirement.
(cherry picked from commit c81478d)
  • Loading branch information
dpobel committed Nov 16, 2012
1 parent 3fc1347 commit 42bb020
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion classes/ezfezpsolrquerybuilder.php
Expand Up @@ -453,7 +453,8 @@ public function buildSearch( $searchText, $params = array(), $searchTypes = arra
eZSolr::getMetaFieldName( 'id' ) . ' ' . eZSolr::getMetaFieldName( 'main_node_id' ) . ' ' .
eZSolr::getMetaFieldName( 'language_code' ) . ' ' . eZSolr::getMetaFieldName( 'name' ) .
' score ' . eZSolr::getMetaFieldName( 'published' ) . ' ' . eZSolr::getMetaFieldName( 'path_string' ) . ' ' .
eZSolr::getMetaFieldName( 'is_invisible' ) . ' ' . implode( ' ', $extraFieldsToReturn );
eZSolr::getMetaFieldName( 'main_path_string' ) . ' ' . eZSolr::getMetaFieldName( 'is_invisible' ) . ' ' .
implode( ' ', $extraFieldsToReturn );

if ( ! $asObjects )
{
Expand Down
27 changes: 19 additions & 8 deletions search/plugins/ezsolr/ezsolr.php
Expand Up @@ -335,6 +335,23 @@ protected function getUrlAlias( $doc )
protected function getNodeID( $doc )
{
$docPathStrings = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'path_string' )];
$docVisibilities = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'is_invisible' )];
if ( count( $docPathStrings ) > 1 )
{
// reordering the path strings and the associated visibilities so
// that the main node path string and the main node visibility are
// in the first position.
$mainNodeIdx = array_search(
$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_path_string' )],
$docPathStrings
);
if ( $mainNodeIdx != 0 )
{
array_unshift( $docVisibilities, $docVisibilities[$mainNodeIdx] );
array_unshift( $docPathStrings, $docPathStrings[$mainNodeIdx] );
unset( $docVisibilities[$mainNodeIdx], $docPathStrings[$mainNodeIdx] );
}
}
$locationFilter = isset( $this->postSearchProcessingData['subtree_array'] ) ? $this->postSearchProcessingData['subtree_array'] : array();
$subtreeLimitations = isset( $this->postSearchProcessingData['subtree_limitations'] ) ? $this->postSearchProcessingData['subtree_limitations'] : array();
$validSubtreeArray = $this->getValidPathStringsByLimitation(
Expand Down Expand Up @@ -365,10 +382,7 @@ protected function getNodeID( $doc )
{
if ( isset( $validSubtrees[$path] ) )
{
if (
$ignoreVisibility ||
!$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'is_invisible' )][$k]
)
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
Expand Down Expand Up @@ -397,10 +411,7 @@ protected function getNodeID( $doc )
}
foreach ( $docPathStrings as $k => $path )
{
if (
$ignoreVisibility ||
!$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'is_invisible' )][$k]
)
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
Expand Down

0 comments on commit 42bb020

Please sign in to comment.