Skip to content

Commit 3503fcd

Browse files
committed
fixup! IBX-6773: Bookmarks for non-accessible contents cause exception: Added BookmarkId sort clause
1 parent 598fc41 commit 3503fcd

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace eZ\Publish\API\Repository\Values\Content\Query\SortClause;
10+
11+
use eZ\Publish\API\Repository\Values\Content\Query;
12+
use eZ\Publish\API\Repository\Values\Content\Query\SortClause;
13+
use eZ\Publish\SPI\Repository\Values\Filter\FilteringSortClause;
14+
15+
/**
16+
* Sets sort direction on the bookmark id for a location query containing a Bookmark criterion.
17+
*/
18+
class BookmarkId extends SortClause implements FilteringSortClause
19+
{
20+
/**
21+
* Constructs a new BookmarkId SortClause.
22+
*
23+
* @param string $sortDirection
24+
*/
25+
public function __construct(string $sortDirection = Query::SORT_ASC)
26+
{
27+
parent::__construct('id', $sortDirection);
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace eZ\Publish\Core\Persistence\Legacy\Filter\SortClauseQueryBuilder\Bookmark;
10+
11+
use eZ\Publish\API\Repository\Values\Content\Query\SortClause\BookmarkId;
12+
use eZ\Publish\SPI\Persistence\Filter\Doctrine\FilteringQueryBuilder;
13+
use eZ\Publish\SPI\Repository\Values\Filter\FilteringSortClause;
14+
use eZ\Publish\SPI\Repository\Values\Filter\SortClauseQueryBuilder;
15+
16+
class IdSortClauseQueryBuilder implements SortClauseQueryBuilder
17+
{
18+
public function accepts(FilteringSortClause $sortClause): bool
19+
{
20+
return $sortClause instanceof BookmarkId;
21+
}
22+
23+
public function buildQuery(
24+
FilteringQueryBuilder $queryBuilder,
25+
FilteringSortClause $sortClause
26+
): void {
27+
/** @var \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause */
28+
$queryBuilder->addOrderBy('bookmark.id', $sortClause->direction);
29+
}
30+
}

eZ/Publish/Core/Repository/BookmarkService.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function loadBookmarks(int $offset = 0, int $limit = 25): BookmarkList
104104
try {
105105
$filter
106106
->withCriterion(new Criterion\Bookmark($currentUserId))
107-
->withSortClause(new SortClause\DatePublished(Query::SORT_DESC))
107+
->withSortClause(new SortClause\BookmarkId(Query::SORT_DESC))
108108
->sliceBy($limit, $offset);
109109

110110
$result = $this->repository->getlocationService()->find($filter, []);

0 commit comments

Comments
 (0)