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

Subtree Criterion don't handle properly subtrees without the last slash

    XMLWordPrintable

Details

    Description

      Detected while testing EZP-22930.
      If you make a Criterion\Subtree search with an a node which value is a substring of another node, the results won't be displayed correctly.

      This happens because Content/Search/Gateway/CriterionHandler/Subtree.php, line #54

      $statements = array();
      foreach ( $criterion->value as $pattern )
      {
      	$statements[] = $query->expr->like(
      		$this->dbHandler->quoteColumn( 'path_string', $table ),
      		$query->bindValue( $pattern . '%' )
      	);
      }
      

      Instead concatenation a "%" to $pattern, the code should confirm if $pattern ends with a "/" and, if not, append instead a "/%"

      Steps to reproduce

      1. Create some folder. Take note of its location (I'll assume the nodeID is 120).
      2. Create four articles under the folder and name them: eZTest #001, eZTest #002, eZTest #003, eZTest #004
      3. Create a command that performs a search with a Criterion\Subtree
        $filter = array(
        	'filter' => new Criterion\LogicalAnd( array(
        		new Criterion\FullText( $text ),
        		new Criterion\Subtree( $subtree )
        	) )
        );
          
        $query = new Query( $filter );
        
      4. Execute the command using /1/2/12 value for $subtree
        php ezpublish/console teste:mysearch "eZTest" /1/2/12
        
      5. Execute the command using /1/2/12/ value for $subtree
        php ezpublish/console teste:mysearch "eZTest" /1/2/12/
        

      Attachments

        Activity

          People

            Unassigned Unassigned
            eduardo.fernandes-obsolete@ez.no Eduardo Fernandes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 45 minutes
                3h 45m