From 94b77034f595911046f2f236e7f04ce1d3e5fd28 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 12 Oct 2023 10:54:10 +0200 Subject: [PATCH] IBX-6631: Simplified the solution --- .../Core/Persistence/Cache/TrashHandler.php | 8 +++--- .../Legacy/Content/Location/Mapper.php | 2 +- .../Legacy/Content/Location/Trash/Handler.php | 27 ++++++++++++++----- .../Content/Location/Trash/Handler.php | 8 +++--- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/eZ/Publish/Core/Persistence/Cache/TrashHandler.php b/eZ/Publish/Core/Persistence/Cache/TrashHandler.php index db9baee5e8..78e9e0eb0c 100644 --- a/eZ/Publish/Core/Persistence/Cache/TrashHandler.php +++ b/eZ/Publish/Core/Persistence/Cache/TrashHandler.php @@ -7,7 +7,6 @@ namespace eZ\Publish\Core\Persistence\Cache; use eZ\Publish\API\Repository\Values\Content\Query\Criterion; -use eZ\Publish\SPI\Persistence\Content\Location; use eZ\Publish\SPI\Persistence\Content\Location\Trash\Handler as TrashHandlerInterface; use eZ\Publish\SPI\Persistence\Content\Relation; @@ -20,11 +19,14 @@ class TrashHandler extends AbstractHandler implements TrashHandlerInterface private const CONTENT_IDENTIFIER = 'content'; private const LOCATION_PATH_IDENTIFIER = 'location_path'; - public function loadTrashItem(int $id, array $trashedLocationsContentMap = []): Location\Trashed + /** + * {@inheritdoc} + */ + public function loadTrashItem($id) { $this->logger->logCall(__METHOD__, ['id' => $id]); - return $this->persistenceHandler->trashHandler()->loadTrashItem($id, $trashedLocationsContentMap); + return $this->persistenceHandler->trashHandler()->loadTrashItem($id); } /** diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Mapper.php b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Mapper.php index f45903c26a..b9d213c4a4 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Mapper.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Mapper.php @@ -25,7 +25,7 @@ class Mapper * @param string $prefix * @param \eZ\Publish\SPI\Persistence\Content\Location|null $location * - * @return \eZ\Publish\SPI\Persistence\Content\Location|\eZ\Publish\SPI\Persistence\Content\Location\Trashed + * @return \eZ\Publish\SPI\Persistence\Content\Location */ public function createLocationFromRow(array $data, $prefix = '', ?Location $location = null) { diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Trash/Handler.php b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Trash/Handler.php index ac974ac1fe..07fe1276df 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Trash/Handler.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Trash/Handler.php @@ -74,15 +74,21 @@ public function __construct( $this->contentHandler = $contentHandler; } - public function loadTrashItem(int $id, array $trashedLocationsContentMap = []): Trashed + /** + * Loads the data for the trashed location identified by $id. + * $id is the same as original location (which has been previously trashed). + * + * @param int $id + * + * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException + * + * @return \eZ\Publish\SPI\Persistence\Content\Location\Trashed + */ + public function loadTrashItem($id) { $data = $this->locationGateway->loadTrashByLocation($id); - return $this->locationMapper->createLocationFromRow( - $data, - null, - new Trashed(['removedLocationContentIdMap' => $trashedLocationsContentMap]), - ); + return $this->locationMapper->createLocationFromRow($data, null, new Trashed()); } /** @@ -139,7 +145,14 @@ public function trashSubtree($locationId) $this->locationHandler->markSubtreeModified($parentLocationId, time()); } - return $isLocationRemoved ? null : $this->loadTrashItem($locationId, $trashedLocationsContentMap); + if ($isLocationRemoved === true) { + return null; + } + + $trashItem = $this->loadTrashItem($locationId); + $trashItem->removedLocationContentIdMap = $trashedLocationsContentMap; + + return $trashItem; } /** diff --git a/eZ/Publish/SPI/Persistence/Content/Location/Trash/Handler.php b/eZ/Publish/SPI/Persistence/Content/Location/Trash/Handler.php index 2385d3b74b..4eda8ce721 100644 --- a/eZ/Publish/SPI/Persistence/Content/Location/Trash/Handler.php +++ b/eZ/Publish/SPI/Persistence/Content/Location/Trash/Handler.php @@ -7,8 +7,6 @@ namespace eZ\Publish\SPI\Persistence\Content\Location\Trash; use eZ\Publish\API\Repository\Values\Content\Query\Criterion; -use eZ\Publish\SPI\Persistence\Content\Location; -use eZ\Publish\SPI\Persistence\Content\Location\Trashed; /** * The Trash Handler interface defines operations on Location elements in the storage engine. @@ -19,11 +17,13 @@ interface Handler * Loads the data for the trashed location identified by $id. * $id is the same as original location (which has been previously trashed). * - * @param array $trashedLocationsContentMap + * @param int $id * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException + * + * @return \eZ\Publish\SPI\Persistence\Content\Location\Trashed */ - public function loadTrashItem(int $id, array $trashedLocationsContentMap = []): Trashed; + public function loadTrashItem($id); /** * Sends a subtree starting to $locationId to the trash