Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-24021

Link is wrong with non-main nodes using 'subtree_array'

    Details

      Description

      When using eZ Find 'subtree_array' in a fetch, the returned results always point to their respective main parent nodes.Non-main nodes are not considered.

      Steps to reproduce:

      1. Create the following content structure:

      Article 1 (node_id: 158, main location)
      	Article 1.1
      Article 2 (node_id: 160)
      

      2. Add "Article 2" as a second location for "Article 1.1". "Article 1" is still the main location. You should have the following structure:

      Article 1 (node_id: 158, main location)
      	Article 1.1
      Article 2 (node_id: 160)
      	Article 1.1
      

      3. Search for "Article 1.1" in "Article 1" => OK, search result points to "Article-1/Article-1.1".

      Used this fetch on search.tpl template ('eng' frontend siteaccess):

      {set $search=fetch( ezfind,search,
                              hash( 'query', $search_text,
                                    'subtree_array', array(158) )
                                   )}
      

      Then went to "example.com/eng/content/search" and searched for "Article 1.1". Result - "Article 1.1" - points to "Article-1/Article-1.1", which is OK.

      4. Search for "Article 1.1" in "Article 2" => OK, search result points to "Article-2/Article-1.1".

      Used this fetch on search.tpl template ('eng' frontend siteaccess):

      {set $search=fetch( ezfind,search,
                              hash( 'query', $search_text,
                                    'subtree_array', array(160) )
                                   )}
      

      Then went to "example.com/eng/content/search" and searched for "Article 1.1". Result - "Article 1.1" - points to "Article-2/Article-1.1", which is OK.

      5. Change "Article 1.1" main location from "Article 1" to "Article 2":

      Article 1 (node_id: 158)
      	Article 1.1
      Article 2 (node_id: 160, main location)
      	Article 1.1
      

      6. Redo steps 3 and 4 => Incorrect, each search result now points to "Article-2/Article-1.1".

        Issue Links

          Activity

          Hide
          Nuno Oliveira (Inactive) added a comment -

          Note:

          According to customer, there is a possible mistake in "/ezfind/search/plugins/ezsolr.php" in "getNodeID" function on the code below:

           if ( $mainNodeIdx != 0 )
          {
          	array_unshift( $docVisibilities, $docVisibilities[$mainNodeIdx] );
          	array_unshift( $docPathStrings, $docPathStrings[$mainNodeIdx] );
          	unset( $docVisibilities[$mainNodeIdx], $docPathStrings[$mainNodeIdx] );
          }
          

          Unshifting the arrays adds a new entry at the beginning of the arrays, so the unset instruction should be :

          unset( $docVisibilities[$mainNodeIdx+1], $docPathStrings[$mainNodeIdx+1] );
          

          With this update, the results are correct when a search is performed in a subtree. But the customer is not sure about the consequences, especially without a subtree limitation, in which case they don't get the main node as expected.

          Show
          Nuno Oliveira (Inactive) added a comment - Note: According to customer, there is a possible mistake in "/ezfind/search/plugins/ezsolr.php" in "getNodeID" function on the code below: if ( $mainNodeIdx != 0 ) { array_unshift( $docVisibilities, $docVisibilities[$mainNodeIdx] ); array_unshift( $docPathStrings, $docPathStrings[$mainNodeIdx] ); unset( $docVisibilities[$mainNodeIdx], $docPathStrings[$mainNodeIdx] ); } Unshifting the arrays adds a new entry at the beginning of the arrays, so the unset instruction should be : unset( $docVisibilities[$mainNodeIdx+1], $docPathStrings[$mainNodeIdx+1] ); With this update, the results are correct when a search is performed in a subtree. But the customer is not sure about the consequences, especially without a subtree limitation, in which case they don't get the main node as expected.
          Hide
          Yannick Roger (Inactive) added a comment -

          The customer's fix looks valid.

          I can not reproduce the side effect the fix introduces that they are mentioning. Can we have more information about it ?

          Show
          Yannick Roger (Inactive) added a comment - The customer's fix looks valid. I can not reproduce the side effect the fix introduces that they are mentioning. Can we have more information about it ?
          Show
          Yannick Roger (Inactive) added a comment - PR: https://github.com/ezsystems/ezfind/pull/190
          Show
          Yannick Roger (Inactive) added a comment - Fixed in master: https://github.com/ezsystems/ezfind/commit/dfd510afb2080ffd176e7ade544136885cb318a0
          Hide
          Rui Silva (Inactive) added a comment -

          Tested and approved by QA.
          Side-effects by the proposed fix evinced by customer could not be reproduced.

          Show
          Rui Silva (Inactive) added a comment - Tested and approved by QA. Side-effects by the proposed fix evinced by customer could not be reproduced.

            People

            • Assignee:
              Unassigned
              Reporter:
              Nuno Oliveira (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: