diff --git a/eZ/Publish/Core/Repository/BookmarkService.php b/eZ/Publish/Core/Repository/BookmarkService.php index 6a6cc9f926..6b52fe684d 100644 --- a/eZ/Publish/Core/Repository/BookmarkService.php +++ b/eZ/Publish/Core/Repository/BookmarkService.php @@ -21,6 +21,8 @@ use eZ\Publish\SPI\Persistence\Bookmark\Handler as BookmarkHandler; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; class BookmarkService implements BookmarkServiceInterface { @@ -30,16 +32,16 @@ class BookmarkService implements BookmarkServiceInterface /** @var \eZ\Publish\SPI\Persistence\Bookmark\Handler */ protected $bookmarkHandler; + private LoggerInterface $logger; + /** * BookmarkService constructor. - * - * @param \eZ\Publish\API\Repository\Repository $repository - * @param \eZ\Publish\SPI\Persistence\Bookmark\Handler $bookmarkHandler */ - public function __construct(RepositoryInterface $repository, BookmarkHandler $bookmarkHandler) + public function __construct(RepositoryInterface $repository, BookmarkHandler $bookmarkHandler, LoggerInterface $logger = null) { $this->repository = $repository; $this->bookmarkHandler = $bookmarkHandler; + $this->logger = $logger ?? new NullLogger(); } /** @@ -110,6 +112,8 @@ public function loadBookmarks(int $offset = 0, int $limit = 25): BookmarkList $result = $this->repository->getlocationService()->find($filter, []); } catch (BadStateException $e) { + $this->logger->debug($e); + return new BookmarkList(); } diff --git a/eZ/Publish/Core/Repository/Repository.php b/eZ/Publish/Core/Repository/Repository.php index a1459a7a8f..028bb5ca20 100644 --- a/eZ/Publish/Core/Repository/Repository.php +++ b/eZ/Publish/Core/Repository/Repository.php @@ -599,7 +599,8 @@ public function getBookmarkService(): BookmarkServiceInterface if ($this->bookmarkService === null) { $this->bookmarkService = new BookmarkService( $this, - $this->persistenceHandler->bookmarkHandler() + $this->persistenceHandler->bookmarkHandler(), + $this->logger ); }