Skip to content

Commit

Permalink
fixup! IBX-6773: Bookmarks for non-accessible contents cause exceptio…
Browse files Browse the repository at this point in the history
…n - Added logger in BookmarkService
  • Loading branch information
vidarl committed Oct 3, 2024
1 parent 2665578 commit f208d3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions eZ/Publish/Core/Repository/BookmarkService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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();
}

/**
Expand Down Expand Up @@ -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();
}

Expand Down
3 changes: 2 additions & 1 deletion eZ/Publish/Core/Repository/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down

0 comments on commit f208d3d

Please sign in to comment.