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

Paging a ContentSearch Result with Subtree Criterion failed

    XMLWordPrintable

Details

    Description

      I have 5 article objects in my content tree, each with at least 2 locations!

      Content structure:

      Content > Folder1 > Folder1.1 > Article1 (Second Location)
      
      Content > Folder1 > Folder1.2 > Article2 (Second Location)
      Content > Folder1 > Folder1.2 > Article3 (Second Location)
      Content > Folder1 > Folder1.2 > Article4 (Second Location)
      Content > Folder1 > Folder1.2 > Article5 (Second Location)
      
      Content > Folder2 > Article1 (Main Location)
      
      Content > Folder3 > Article2 (Main Location)
      Content > Folder3 > Article3 (Main Location)
      
      Content > Folder4 > Article4 (Main Location)
      Content > Folder4 > Article5 (Main Location)
      

      Content Search Code:

      search.php
      $criteria = array(
          new Criterion\Subtree('/1/2/'),
          new Criterion\Visibility(Criterion\Visibility::VISIBLE),
          new Criterion\ContentTypeIdentifier('article');
      );
      
      $query = new Query(
          array(
              'criterion' => new Criterion\LogicalAnd($criteria),
              'sortClauses' => array(
                    new SortClause\ContentId(Query::SORT_DESC)
              )
          )
      );
      
      $pager = new Pagerfanta(new ContentSearchAdapter($query, $this->repository->getSearchService()));
      $pager->setMaxPerPage(3);
      $pager->setCurrentPage(1);
      
      echo "Count 1:" . $pager->count();
      echo "Count 2:" . count($pager);
      
      foreach($pager as $item) {
          echo "Object Name:" . $item->contentInfo->name;
      }
      

      Result:

      Count 1:5
      Count 2:5
      Object Name: Object 5
      Object Name: Object 4
      

      As you can see, one object ist missing for the current page.

      Result without Subtree Criterion:

      Count 1:5
      Count 2:5
      Object Name: Object 5
      Object Name: Object 4
      Object Name: Object 3
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            daniel.schreier daniel.schreier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: