Skip to content

Commit

Permalink
fixup! IBX-6773: Bookmarks for non-accessible contents cause exception
Browse files Browse the repository at this point in the history
  • Loading branch information
vidarl committed Jun 7, 2024
1 parent ddca556 commit 023111b
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* Supported operators:
* - EQ: matches against a unique user id
*/
class Bookmark extends Criterion implements FilteringCriterion
class IsBookmarked extends Criterion implements FilteringCriterion
{
/**
* Creates a new Bookmark criterion.
* Creates a new IsBookmarked criterion.
*
* @param int $value UserID for which bookmarked locations must be matched against
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use eZ\Publish\SPI\Repository\Values\Filter\FilteringSortClause;

/**
* Sets sort direction on the bookmark id for a location query containing a Bookmark criterion.
* Sets sort direction on the Bookmark ID for a location query containing a IsBookmarked criterion.
*/
class BookmarkId extends SortClause implements FilteringSortClause
{
Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/Persistence/Cache/BookmarkHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function (Bookmark $bookmark) {
}

/**
* @deprecated Please use LocationService::find() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::find() and Criterion\IsBookmarked instead.
*
* {@inheritdoc}
*/
Expand All @@ -101,7 +101,7 @@ public function loadUserBookmarks(int $userId, int $offset = 0, int $limit = -1)
}

/**
* @deprecated Please use LocationService::count() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::count() and Criterion\IsBookmarked instead.
*
* {@inheritdoc}
*/
Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/Persistence/Legacy/Bookmark/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract public function loadBookmarkDataByUserIdAndLocationId(int $userId, arra
/**
* Load data for all bookmarks owned by given $userId.
*
* @deprecated Please use LocationService::find() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::find() and Criterion\IsBookmarked instead.
*
* @param int $userId ID of user
* @param int $offset Offset to start listing from, 0 by default
Expand All @@ -57,7 +57,7 @@ abstract public function loadUserBookmarks(int $userId, int $offset = 0, int $li
/**
* Count bookmarks owned by given $userId.
*
* @deprecated Please use LocationService::count() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::count() and Criterion\IsBookmarked instead.
*
* @param int $userId ID of user
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function loadBookmarkDataByUserIdAndLocationId(int $userId, array $locati
}

/**
* @deprecated Please use LocationService::find() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::find() and Criterion\IsBookmarked instead.
*
* {@inheritdoc}
*/
Expand All @@ -125,7 +125,7 @@ public function loadUserBookmarks(int $userId, int $offset = 0, int $limit = -1)
}

/**
* @deprecated Please use LocationService::count() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::count() and Criterion\IsBookmarked instead.
*
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function loadBookmarkDataByUserIdAndLocationId(int $userId, array $locati
}

/**
* @deprecated Please use LocationService::find() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::find() and Criterion\IsBookmarked instead.
*
* @param int $userId
* @param int $offset
Expand All @@ -75,7 +75,7 @@ public function loadUserBookmarks(int $userId, int $offset = 0, int $limit = -1)
}

/**
* @deprecated Please use LocationService::count() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::count() and Criterion\IsBookmarked instead.
*
* @param int $userId
*
Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/Persistence/Legacy/Bookmark/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function loadByUserIdAndLocationId(int $userId, array $locationIds): arra
}

/**
* @deprecated Please use LocationService::find() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::find() and Criterion\IsBookmarked instead.
*
* {@inheritdoc}
*/
Expand All @@ -86,7 +86,7 @@ public function loadUserBookmarks(int $userId, int $offset = 0, int $limit = -1)
}

/**
* @deprecated Please use LocationService::count() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::count() and Criterion\IsBookmarked instead.
*
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace eZ\Publish\Core\Persistence\Legacy\Filter\CriterionQueryBuilder\Location;

use Doctrine\DBAL\ParameterType;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Bookmark;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\IsBookmarked;
use eZ\Publish\Core\Persistence\Legacy\Bookmark\Gateway\DoctrineDatabase;
use eZ\Publish\SPI\Persistence\Filter\Doctrine\FilteringQueryBuilder;
use eZ\Publish\SPI\Repository\Values\Filter\FilteringCriterion;
Expand All @@ -21,7 +21,7 @@ final class BookmarkQueryBuilder extends BaseLocationCriterionQueryBuilder
{
public function accepts(FilteringCriterion $criterion): bool
{
return $criterion instanceof Bookmark;
return $criterion instanceof IsBookmarked;
}

public function buildQueryConstraint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ final class BookmarkQueryBuilderTest extends BaseCriterionVisitorQueryBuilderTes
public function getFilteringCriteriaQueryData(): iterable
{
yield 'Bookmarks locations for user_id=14' => [
new Criterion\Bookmark(14),
new Criterion\IsBookmarked(14),
'bookmark.user_id = :dcValue1',
['dcValue1' => 14],
];

yield 'Bookmarks locations for user_id=14 OR user_id=7' => [
new Criterion\LogicalOr(
[
new Criterion\Bookmark(14),
new Criterion\Bookmark(7),
new Criterion\IsBookmarked(14),
new Criterion\IsBookmarked(7),
]
),
'(bookmark.user_id = :dcValue1) OR (bookmark.user_id = :dcValue2)',
Expand Down
2 changes: 1 addition & 1 deletion eZ/Publish/Core/Repository/BookmarkService.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function loadBookmarks(int $offset = 0, int $limit = 25): BookmarkList
$filter = new Filter();
try {
$filter
->withCriterion(new Criterion\Bookmark($currentUserId))
->withCriterion(new Criterion\IsBookmarked($currentUserId))
->withSortClause(new SortClause\BookmarkId(Query::SORT_DESC))
->sliceBy($limit, $offset);

Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/SPI/Persistence/Bookmark/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function loadByUserIdAndLocationId(int $userId, array $locationIds): arra
/**
* Loads bookmarks owned by user.
*
* @deprecated Please use LocationService::find() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::find() and Criterion\IsBookmarked instead.
*
* @param int $userId
* @param int $offset the start offset for paging
Expand All @@ -54,7 +54,7 @@ public function loadUserBookmarks(int $userId, int $offset = 0, int $limit = -1)
/**
* Count bookmarks owned by user.
*
* @deprecated Please use LocationService::count() and Criterion\Bookmark instead.
* @deprecated Please use LocationService::count() and Criterion\IsBookmarked instead.
*
* @param int $userId
*
Expand Down

0 comments on commit 023111b

Please sign in to comment.