From bec9345d2539040de56ea00ea2c76c4a46846f79 Mon Sep 17 00:00:00 2001 From: Jacek Foremski Date: Thu, 17 May 2018 13:36:43 +0200 Subject: [PATCH] EZP-27948: When swapping Locations with the same name and parent, URL aliases are not swapped as well (#2297) * EZP-27948: When swapping Locations with the same name and parent, URL aliases are not swapped as well * Optimized UrlAlias Persistence Handler::getLocationEntryInLanguage * Refactored UrlAlias Persistence Handler::locationSwapped Using internal DTOs instead of multiple variables for readablity --- .../Repository/Tests/LocationServiceTest.php | 2 +- .../Persistence/Legacy/Content/Gateway.php | 13 + .../Content/Gateway/DoctrineDatabase.php | 85 +++-- .../Content/Gateway/ExceptionConversion.php | 22 ++ .../DTO/SwappedLocationProperties.php | 56 ++++ .../DTO/UrlAliasForSwappedLocation.php | 59 ++++ .../Legacy/Content/UrlAlias/Handler.php | 252 +++++++++++--- .../Content/UrlAlias/UrlAliasHandlerTest.php | 307 +++++++++++++++++- ...iases_swap_multilang_cleanup_composite.php | 34 ++ .../urlaliases_swap_multilang_diff.php | 40 +++ .../urlaliases_swap_multilang_diff_simple.php | 28 ++ ...p_multilang_path_identification_string.php | 28 ++ .../urlaliases_swap_multilang_simple.php | 28 ++ ...liases_swap_path_identification_string.php | 16 + ...laliases_swap_reusing_external_history.php | 16 + .../_fixtures/urlaliases_swap_reusing_nop.php | 16 + .../urlaliases_swap_siblings_same_name.php | 119 +++++++ ...ases_swap_siblings_same_name_multilang.php | 163 ++++++++++ .../urlaliases_swap_siblings_simple.php | 16 + ...rlaliases_swap_siblings_simple_history.php | 16 + .../_fixtures/urlaliases_swap_simple.php | 16 + .../urlaliases_swap_simple_conflict.php | 16 + .../urlaliases_swap_simple_history.php | 16 + .../storage_engines/legacy/url_alias.yml | 2 + 24 files changed, 1293 insertions(+), 73 deletions(-) create mode 100644 eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/DTO/SwappedLocationProperties.php create mode 100644 eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/DTO/UrlAliasForSwappedLocation.php create mode 100644 eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name.php create mode 100644 eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name_multilang.php diff --git a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php index df80c7a2013..c6978a6e9bb 100644 --- a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php +++ b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php @@ -1122,7 +1122,7 @@ public function testSwapLocation() ); $this->assertEquals( $demoDesignLocation->id, - $repository->getURLAliasService()->lookup('/Plain-site')->destination + $repository->getURLAliasService()->lookup('/eZ-Publish-Demo-Design-without-demo-content')->destination ); } diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway.php index 74209c52d65..9c507883d7e 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway.php @@ -162,6 +162,19 @@ abstract public function load($contentId, $version, array $translations = null); */ abstract public function loadContentInfoByRemoteId($remoteId); + /** + * Loads info for a content object identified by its location ID (node ID). + * + * Returns an array with the relevant data. + * + * @param int $locationId + * + * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException + * + * @return array + */ + abstract public function loadContentInfoByLocationId($locationId); + /** * Loads info for content identified by $contentId. * Will basically return a hash containing all field values for ezcontentobject table plus following keys: diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php index d7fef3f36fc..0fc20f6c703 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php @@ -850,19 +850,14 @@ public function load($contentId, $version, array $translations = null) } /** - * @see loadContentInfo(), loadContentInfoByRemoteId() + * @see loadContentInfo(), loadContentInfoByRemoteId(), loadContentInfoByLocationId() * - * @param string $column - * @param mixed $id - * - * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException + * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query * * @return array */ - private function internalLoadContentInfo($column, $id) + private function internalLoadContentInfo(SelectQuery $query) { - /** @var $query \eZ\Publish\Core\Persistence\Database\SelectQuery */ - $query = $this->dbHandler->createSelectQuery(); $query->select( 'ezcontentobject.*', $this->dbHandler->aliasedColumn($query, 'main_node_id', 'ezcontentobject_tree') @@ -880,21 +875,11 @@ private function internalLoadContentInfo($column, $id) $this->dbHandler->quoteColumn('node_id', 'ezcontentobject_tree') ) ) - )->where( - $query->expr->eq( - $this->dbHandler->quoteColumn($column, 'ezcontentobject'), - $query->bindValue($id, null, $column === 'id' ? PDO::PARAM_INT : PDO::PARAM_STR) - ) ); $statement = $query->prepare(); $statement->execute(); - $row = $statement->fetch(PDO::FETCH_ASSOC); - if (empty($row)) { - throw new NotFound('content', "$column: $id"); - } - - return $row; + return $statement->fetch(PDO::FETCH_ASSOC); } /** @@ -911,7 +896,21 @@ private function internalLoadContentInfo($column, $id) */ public function loadContentInfo($contentId) { - return $this->internalLoadContentInfo('id', $contentId); + $query = $this->dbHandler->createSelectQuery(); + $query->where( + $query->expr->eq( + $this->dbHandler->quoteColumn('id', 'ezcontentobject'), + $query->bindValue($contentId, null, PDO::PARAM_INT) + ) + ); + + $row = $this->internalLoadContentInfo($query); + + if (empty($row)) { + throw new NotFound('content', "id: $contentId"); + } + + return $row; } /** @@ -927,7 +926,51 @@ public function loadContentInfo($contentId) */ public function loadContentInfoByRemoteId($remoteId) { - return $this->internalLoadContentInfo('remote_id', $remoteId); + $query = $this->dbHandler->createSelectQuery(); + $query->where( + $query->expr->eq( + $this->dbHandler->quoteColumn('remote_id', 'ezcontentobject'), + $query->bindValue($remoteId) + ) + ); + + $row = $this->internalLoadContentInfo($query); + + if (empty($row)) { + throw new NotFound('content', "remote_id: $remoteId"); + } + + return $row; + } + + /** + * Loads info for a content object identified by its location ID (node ID). + * + * Returns an array with the relevant data. + * + * @param int $locationId + * + * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException + * + * @return array + */ + public function loadContentInfoByLocationId($locationId) + { + $query = $this->dbHandler->createSelectQuery(); + $query->where( + $query->expr->eq( + $this->dbHandler->quoteColumn('main_node_id', 'ezcontentobject_tree'), + $query->bindValue($locationId, null, PDO::PARAM_INT) + ) + ); + + $row = $this->internalLoadContentInfo($query); + + if (empty($row)) { + throw new NotFound('content', "main_node_id: $locationId"); + } + + return $row; } /** diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php index 698ae278702..8042fd01f5d 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php @@ -296,6 +296,28 @@ public function loadContentInfoByRemoteId($remoteId) } } + /** + * Loads info for a content object identified by its location ID (node ID). + * + * Returns an array with the relevant data. + * + * @param int $locationId + * + * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException + * + * @return array + */ + public function loadContentInfoByLocationId($locationId) + { + try { + return $this->innerGateway->loadContentInfoByLocationId($locationId); + } catch (DBALException $e) { + throw new \RuntimeException('Database error', 0, $e); + } catch (\PDOException $e) { + throw new \RuntimeException('Database error', 0, $e); + } + } + /** * Loads info for content identified by $contentId. * Will basically return a hash containing all field values for ezcontentobject table plus following keys: diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/DTO/SwappedLocationProperties.php b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/DTO/SwappedLocationProperties.php new file mode 100644 index 00000000000..eda00a26f97 --- /dev/null +++ b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/DTO/SwappedLocationProperties.php @@ -0,0 +1,56 @@ +id = $id; + $this->parentId = $parentId; + } + + /** + * @var int + */ + public $id; + + /** + * @var int + */ + public $parentId; + + /** + * @var string + */ + public $name; + + /** + * @var int + */ + public $mainLanguageId; + + /** + * @var int + */ + public $autogeneratedId; + + /** + * @var bool + */ + public $isAlwaysAvailable; + + /** + * Raw database records (entries). + * + * @var array + */ + public $entries; +} diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/DTO/UrlAliasForSwappedLocation.php b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/DTO/UrlAliasForSwappedLocation.php new file mode 100644 index 00000000000..e898d4f17fb --- /dev/null +++ b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/DTO/UrlAliasForSwappedLocation.php @@ -0,0 +1,59 @@ +id = $id; + $this->parentId = $parentId; + $this->name = $name; + $this->isAlwaysAvailable = $isAlwaysAvailable; + $this->isPathIdentificationStringModified = $isPathIdentificationStringModified; + $this->newId = $newId; + } + + /** + * @var int + */ + public $id; + + /** + * @var int + */ + public $parentId; + + /** + * @var string + */ + public $name; + + /** + * @var bool + */ + public $isAlwaysAvailable; + + /** + * @var bool + */ + public $isPathIdentificationStringModified; + + /** + * @var int + */ + public $newId; +} diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php index 4fb70f35556..c1ade81b465 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php @@ -9,8 +9,14 @@ namespace eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias; use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException; +use eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator; +use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\DTO\SwappedLocationProperties; +use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\DTO\UrlAliasForSwappedLocation; +use eZ\Publish\SPI\Persistence\Content\Language; +use eZ\Publish\SPI\Persistence\Content\UrlAlias; use eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler as UrlAliasHandlerInterface; use eZ\Publish\SPI\Persistence\Content\Language\Handler as LanguageHandler; +use eZ\Publish\Core\Persistence\Legacy\Content\Gateway as ContentGateway; use eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway as LocationGateway; use eZ\Publish\Core\Base\Exceptions\NotFoundException; use eZ\Publish\Core\Base\Exceptions\ForbiddenException; @@ -75,6 +81,20 @@ class Handler implements UrlAliasHandlerInterface */ protected $slugConverter; + /** + * Gateway for handling content data. + * + * @var \eZ\Publish\Core\Persistence\Legacy\Content\Gateway + */ + protected $contentGateway; + + /** + * Language mask generator. + * + * @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator + */ + protected $maskGenerator; + /** * Creates a new UrlAlias Handler. * @@ -83,19 +103,25 @@ class Handler implements UrlAliasHandlerInterface * @param \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway $locationGateway * @param \eZ\Publish\SPI\Persistence\Content\Language\Handler $languageHandler * @param \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter $slugConverter + * @param \eZ\Publish\Core\Persistence\Legacy\Content\Gateway $contentGateway + * @param \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator $maskGenerator */ public function __construct( Gateway $gateway, Mapper $mapper, LocationGateway $locationGateway, LanguageHandler $languageHandler, - SlugConverter $slugConverter + SlugConverter $slugConverter, + ContentGateway $contentGateway, + MaskGenerator $maskGenerator ) { $this->gateway = $gateway; $this->mapper = $mapper; $this->locationGateway = $locationGateway; $this->languageHandler = $languageHandler; $this->slugConverter = $slugConverter; + $this->contentGateway = $contentGateway; + $this->maskGenerator = $maskGenerator; } public function publishUrlAliasForLocation( @@ -616,58 +642,90 @@ public function locationCopied($locationId, $newLocationId, $newParentId) ); } + /** + * Notify the underlying engine that a Location has been swapped. + * + * This method triggers the change of the autogenerated aliases. + * + * @param int $location1Id + * @param int $location1ParentId + * @param int $location2Id + * @param int $location2ParentId + */ public function locationSwapped($location1Id, $location1ParentId, $location2Id, $location2ParentId) { - $location1Entries = $this->gateway->loadLocationEntries($location1Id); - $location2Entries = $this->gateway->loadLocationEntries($location2Id); + $location1 = new SwappedLocationProperties($location1Id, $location1ParentId); + $location2 = new SwappedLocationProperties($location2Id, $location2ParentId); - $location1MainLanguageId = $this->gateway->getLocationContentMainLanguageId($location1Id); - $location2MainLanguageId = $this->gateway->getLocationContentMainLanguageId($location2Id); + $location1->entries = $this->gateway->loadLocationEntries($location1Id); + $location2->entries = $this->gateway->loadLocationEntries($location2Id); + + $location1->mainLanguageId = $this->gateway->getLocationContentMainLanguageId($location1Id); + $location2->mainLanguageId = $this->gateway->getLocationContentMainLanguageId($location2Id); // Load autogenerated entries to find alias ID - $autoLocation1 = $this->gateway->loadAutogeneratedEntry("eznode:{$location1Id}"); - $autoLocation2 = $this->gateway->loadAutogeneratedEntry("eznode:{$location2Id}"); + $location1->autogeneratedId = $this->gateway->loadAutogeneratedEntry("eznode:{$location1Id}")['id']; + $location2->autogeneratedId = $this->gateway->loadAutogeneratedEntry("eznode:{$location2Id}")['id']; - // Historize everything first to avoid name conflicts in case swapped Locations are siblings - $this->historizeBeforeSwap($location1Entries, $location2Entries); + $contentInfo1 = $this->contentGateway->loadContentInfoByLocationId($location1Id); + $contentInfo2 = $this->contentGateway->loadContentInfoByLocationId($location2Id); - foreach ($location2Entries as $row) { - $alwaysAvailable = (bool)($row['lang_mask'] & 1); - $languageIds = $this->extractLanguageIdsFromMask($row['lang_mask']); + $names1 = $this->getNamesForAllLanguages($contentInfo1); + $names2 = $this->getNamesForAllLanguages($contentInfo2); - foreach ($languageIds as $languageId) { - $isMainLanguage = $languageId == $location2MainLanguageId; - $this->internalPublishUrlAliasForLocation( - $location1Id, - $location1ParentId, - $row['text'], - $languageId, - $isMainLanguage && $alwaysAvailable, - $isMainLanguage, - $autoLocation1['id'] - ); - } - } + $location1->isAlwaysAvailable = $this->maskGenerator->isAlwaysAvailable($contentInfo1['language_mask']); + $location2->isAlwaysAvailable = $this->maskGenerator->isAlwaysAvailable($contentInfo2['language_mask']); - foreach ($location1Entries as $row) { - $alwaysAvailable = (bool)($row['lang_mask'] & 1); - $languageIds = $this->extractLanguageIdsFromMask($row['lang_mask']); + $languages = $this->languageHandler->loadAll(); - foreach ($languageIds as $languageId) { - $isMainLanguage = $languageId == $location1MainLanguageId; + // Historize everything first to avoid name conflicts in case swapped Locations are siblings + $this->historizeBeforeSwap($location1->entries, $location2->entries); + + foreach ($languages as $languageCode => $language) { + $location1->name = isset($names1[$languageCode]) ? $names1[$languageCode] : null; + $location2->name = isset($names2[$languageCode]) ? $names2[$languageCode] : null; + $urlAliasesForSwappedLocations = $this->getUrlAliasesForSwappedLocations( + $language, + $location1, + $location2 + ); + foreach ($urlAliasesForSwappedLocations as $urlAliasForLocation) { $this->internalPublishUrlAliasForLocation( - $location2Id, - $location2ParentId, - $row['text'], - $languageId, - $isMainLanguage && $alwaysAvailable, - $isMainLanguage, - $autoLocation2['id'] + $urlAliasForLocation->id, + $urlAliasForLocation->parentId, + $urlAliasForLocation->name, + $language->id, + $urlAliasForLocation->isAlwaysAvailable, + $urlAliasForLocation->isPathIdentificationStringModified, + $urlAliasForLocation->newId ); } } } + /** + * @param array $contentInfo + * + * @return array + */ + private function getNamesForAllLanguages(array $contentInfo) + { + $nameDataArray = $this->contentGateway->loadVersionedNameData([ + [ + 'id' => $contentInfo['id'], + 'version' => $contentInfo['current_version'], + ], + ]); + + $namesForAllLanguages = []; + foreach ($nameDataArray as $nameData) { + $namesForAllLanguages[$nameData['ezcontentobject_name_content_translation']] + = $nameData['ezcontentobject_name_name']; + } + + return $namesForAllLanguages; + } + /** * Historizes given existing active entries for two swapped Locations. * @@ -694,27 +752,121 @@ private function historizeBeforeSwap($location1Entries, $location2Entries) } /** - * Extracts every language Ids contained in $languageMask. + * Decides if UrlAlias for $location2 should be published first. + * + * The order in which Locations are published only matters if swapped Locations are siblings and they have the same + * name in a given language. In this case, the UrlAlias for Location which previously had lower number at the end of + * its UrlAlias text (or no number at all) should be published first. This ensures that the number still stays lower + * for this Location after the swap. If it wouldn't stay lower, then swapping Locations in conjunction with swapping + * UrlAliases would effectively cancel each other. * - * @param int $languageMask + * @param array $location1Entries + * @param int $location1ParentId + * @param string $name1 + * @param array $location2Entries + * @param int $location2ParentId + * @param string $name2 + * @param int $languageId * - * @return int[] An array of language IDs + * @return bool */ - private function extractLanguageIdsFromMask($languageMask) - { - $exp = 2; - $languageIds = []; + private function shouldUrlAliasForSecondLocationBePublishedFirst( + array $location1Entries, + $location1ParentId, + $name1, + array $location2Entries, + $location2ParentId, + $name2, + $languageId + ) { + if ($location1ParentId === $location2ParentId && $name1 === $name2) { + $locationEntry1 = $this->getLocationEntryInLanguage($location1Entries, $languageId); + $locationEntry2 = $this->getLocationEntryInLanguage($location2Entries, $languageId); - // Decomposition of $languageMask into its binary components. - while ($exp <= $languageMask) { - if ($languageMask & $exp) { - $languageIds[] = $exp; + if ($locationEntry1 === null || $locationEntry2 === null) { + return false; } - $exp *= 2; + if ($locationEntry2['text'] < $locationEntry1['text']) { + return true; + } } - return $languageIds; + return false; + } + + /** + * Get in a proper order - to be published - a list of URL aliases for swapped Locations. + * + * @see shouldUrlAliasForSecondLocationBePublishedFirst + * + * @param \eZ\Publish\SPI\Persistence\Content\Language $language + * @param \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\DTO\SwappedLocationProperties $location1 + * @param \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\DTO\SwappedLocationProperties $location2 + * + * @return \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\DTO\UrlAliasForSwappedLocation[] + */ + private function getUrlAliasesForSwappedLocations( + Language $language, + SwappedLocationProperties $location1, + SwappedLocationProperties $location2 + ) { + $isMainLanguage1 = $language->id == $location1->mainLanguageId; + $isMainLanguage2 = $language->id == $location2->mainLanguageId; + $urlAliases = []; + if (isset($location1->name)) { + $urlAliases[] = new UrlAliasForSwappedLocation( + $location1->id, + $location1->parentId, + $location1->name, + $isMainLanguage2 && $location1->isAlwaysAvailable, + $isMainLanguage2, + $location1->autogeneratedId + ); + } + + if (isset($location2->name)) { + $urlAliases[] = new UrlAliasForSwappedLocation( + $location2->id, + $location2->parentId, + $location2->name, + $isMainLanguage1 && $location2->isAlwaysAvailable, + $isMainLanguage1, + $location2->autogeneratedId + ); + + if (isset($location1->name) && $this->shouldUrlAliasForSecondLocationBePublishedFirst( + $location1->entries, + $location1->parentId, + $location1->name, + $location2->entries, + $location2->parentId, + $location2->name, + $language->id + )) { + $urlAliases = array_reverse($urlAliases); + } + } + + return $urlAliases; + } + + /** + * @param array $locationEntries + * @param int $languageId + * + * @return array|null + */ + private function getLocationEntryInLanguage(array $locationEntries, $languageId) + { + $entries = array_filter( + $locationEntries, + function (array $row) use ($languageId) { + return (bool) ($row['lang_mask'] & $languageId); + } + ); + + return !empty($entries) ? array_shift($entries) : null; } /** diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/UrlAliasHandlerTest.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/UrlAliasHandlerTest.php index 14e941cc13f..4d1ba38d139 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/UrlAliasHandlerTest.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/UrlAliasHandlerTest.php @@ -13,6 +13,8 @@ use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Mapper; use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway\DoctrineDatabase; use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter; +use eZ\Publish\Core\Persistence\Legacy\Content\Gateway; +use eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase as ContentGateway; use eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\DoctrineDatabase as DoctrineDatabaseLocation; use eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler as LanguageHandler; use eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase as LanguageGateway; @@ -3869,6 +3871,286 @@ public function testLocationSwappedSiblingsSimpleWithHistoryReverse() ); } + /** + * Test for the locationSwapped() method. + * + * @group swap + */ + public function testLocationSwappedSiblingsSameName() + { + $handler = $this->getHandler(); + $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php'); + + $countBeforeReusing = $this->countRows(); + + $handler->locationSwapped(314, 2, 315, 2); + + $this->assertEquals( + $countBeforeReusing, + $this->countRows() + ); + + $urlAlias = $handler->lookup('swap'); + $this->assertEquals( + new UrlAlias( + [ + 'id' => '0-' . md5('swap'), + 'type' => UrlAlias::LOCATION, + 'destination' => 314, + 'languageCodes' => [ + 'cro-HR', + ], + 'pathData' => [ + [ + 'always-available' => false, + 'translations' => [ + 'cro-HR' => 'swap', + ], + ], + ], + 'alwaysAvailable' => false, + 'isHistory' => false, + 'isCustom' => false, + 'forward' => false, + ] + ), + $urlAlias + ); + + $urlAlias = $handler->lookup('swap2'); + $this->assertEquals( + new UrlAlias( + [ + 'id' => '0-' . md5('swap2'), + 'type' => UrlAlias::LOCATION, + 'destination' => 315, + 'languageCodes' => [ + 'cro-HR', + ], + 'pathData' => [ + [ + 'always-available' => false, + 'translations' => [ + 'cro-HR' => 'swap2', + ], + ], + ], + 'alwaysAvailable' => false, + 'isHistory' => false, + 'isCustom' => false, + 'forward' => false, + ] + ), + $urlAlias + ); + } + + /** + * Test for the locationSwapped() method. + * + * @group swap + */ + public function testLocationSwappedSiblingsSameNameReverse() + { + $handler = $this->getHandler(); + $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php'); + + $countBeforeReusing = $this->countRows(); + + $handler->locationSwapped(315, 2, 314, 2); + + $this->assertEquals( + $countBeforeReusing, + $this->countRows() + ); + + $urlAlias = $handler->lookup('swap'); + $this->assertEquals( + new UrlAlias( + [ + 'id' => '0-' . md5('swap'), + 'type' => UrlAlias::LOCATION, + 'destination' => 314, + 'languageCodes' => [ + 'cro-HR', + ], + 'pathData' => [ + [ + 'always-available' => false, + 'translations' => [ + 'cro-HR' => 'swap', + ], + ], + ], + 'alwaysAvailable' => false, + 'isHistory' => false, + 'isCustom' => false, + 'forward' => false, + ] + ), + $urlAlias + ); + + $urlAlias = $handler->lookup('swap2'); + $this->assertEquals( + new UrlAlias( + [ + 'id' => '0-' . md5('swap2'), + 'type' => UrlAlias::LOCATION, + 'destination' => 315, + 'languageCodes' => [ + 'cro-HR', + ], + 'pathData' => [ + [ + 'always-available' => false, + 'translations' => [ + 'cro-HR' => 'swap2', + ], + ], + ], + 'alwaysAvailable' => false, + 'isHistory' => false, + 'isCustom' => false, + 'forward' => false, + ] + ), + $urlAlias + ); + } + + /** + * Test for the locationSwapped() method. + * + * @group swap + */ + public function testLocationSwappedSiblingsSameNameMultipleLanguages() + { + $handler = $this->getHandler(); + $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name_multilang.php'); + + $countBeforeReusing = $this->countRows(); + + $handler->locationSwapped(314, 2, 315, 2); + + $this->assertEquals( + $countBeforeReusing, + $this->countRows() + ); + + $urlAlias = $handler->lookup('swap-hr'); + $this->assertEquals( + new UrlAlias( + [ + 'id' => '0-' . md5('swap-hr'), + 'type' => UrlAlias::LOCATION, + 'destination' => 314, + 'languageCodes' => [ + 'cro-HR', + ], + 'pathData' => [ + [ + 'always-available' => false, + 'translations' => [ + 'cro-HR' => 'swap-hr', + 'eng-GB' => 'swap-en2', + ], + ], + ], + 'alwaysAvailable' => false, + 'isHistory' => false, + 'isCustom' => false, + 'forward' => false, + ] + ), + $urlAlias + ); + + $urlAlias = $handler->lookup('swap-hr2'); + $this->assertEquals( + new UrlAlias( + [ + 'id' => '0-' . md5('swap-hr2'), + 'type' => UrlAlias::LOCATION, + 'destination' => 315, + 'languageCodes' => [ + 'cro-HR', + ], + 'pathData' => [ + [ + 'always-available' => false, + 'translations' => [ + 'cro-HR' => 'swap-hr2', + 'eng-GB' => 'swap-en', + ], + ], + ], + 'alwaysAvailable' => false, + 'isHistory' => false, + 'isCustom' => false, + 'forward' => false, + ] + ), + $urlAlias + ); + + $urlAlias = $handler->lookup('swap-en'); + $this->assertEquals( + new UrlAlias( + [ + 'id' => '0-' . md5('swap-en'), + 'type' => UrlAlias::LOCATION, + 'destination' => 315, + 'languageCodes' => [ + 'eng-GB', + ], + 'pathData' => [ + [ + 'always-available' => false, + 'translations' => [ + 'cro-HR' => 'swap-hr2', + 'eng-GB' => 'swap-en', + ], + ], + ], + 'alwaysAvailable' => false, + 'isHistory' => false, + 'isCustom' => false, + 'forward' => false, + ] + ), + $urlAlias + ); + + $urlAlias = $handler->lookup('swap-en2'); + $this->assertEquals( + new UrlAlias( + [ + 'id' => '0-' . md5('swap-en2'), + 'type' => UrlAlias::LOCATION, + 'destination' => 314, + 'languageCodes' => [ + 'eng-GB', + ], + 'pathData' => [ + [ + 'always-available' => false, + 'translations' => [ + 'cro-HR' => 'swap-hr', + 'eng-GB' => 'swap-en2', + ], + ], + ], + 'alwaysAvailable' => false, + 'isHistory' => false, + 'isCustom' => false, + 'forward' => false, + ] + ), + $urlAlias + ); + } + /** * Test for the locationSwapped() method. * @@ -5052,6 +5334,20 @@ protected function getPartlyMockedHandler(array $methods) '', false ), + $this->getMock( + Gateway::class, + [], + [], + '', + false + ), + $this->getMock( + LanguageMaskGenerator::class, + [], + [], + '', + false + ), ) ); @@ -5071,13 +5367,22 @@ protected function getHandler() ); $mapper = new Mapper($languageMaskGenerator); $slugConverter = new SlugConverter($this->getProcessor()); + $contentGateway = new ContentGateway( + $this->getDatabaseHandler(), + $this->getDatabaseConnection(), + new ContentGateway\QueryBuilder($this->getDatabaseHandler()), + $languageHandler, + $languageMaskGenerator + ); return new Handler( $gateway, $mapper, $this->getLocationGateway(), $languageHandler, - $slugConverter + $slugConverter, + $contentGateway, + $languageMaskGenerator ); } diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_cleanup_composite.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_cleanup_composite.php index fc0ca955a15..5f6bc43a469 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_cleanup_composite.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_cleanup_composite.php @@ -179,10 +179,44 @@ 0 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 4, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap hr', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap that', + 'content_translation' => 'ger-DE', + ], + 2 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap that', + 'content_translation' => 'nor-NO', + ], + 3 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap this', + 'content_translation' => 'cro-HR', + ], + 4 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap en', + 'content_translation' => 'eng-GB', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff.php index 9bd975006ad..e979937299c 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff.php @@ -179,10 +179,50 @@ 0 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 4, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap hr', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap this', + 'content_translation' => 'ger-DE', + ], + 2 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap this', + 'content_translation' => 'nor-NO', + ], + 3 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap this', + 'content_translation' => 'cro-HR', + ], + 4 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap this', + 'content_translation' => 'ger-DE', + ], + 5 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap en', + 'content_translation' => 'eng-GB', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff_simple.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff_simple.php index 91a2f316171..45a62b40869 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff_simple.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff_simple.php @@ -173,10 +173,38 @@ 0 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 4, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap hr', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap de', + 'content_translation' => 'ger-DE', + ], + 2 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap hr', + 'content_translation' => 'cro-HR', + ], + 3 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap en', + 'content_translation' => 'eng-GB', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_path_identification_string.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_path_identification_string.php index b6ee871801d..866a9405a84 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_path_identification_string.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_path_identification_string.php @@ -132,10 +132,38 @@ 0 => array( 'id' => 2, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 3, 'initial_language_id' => 8, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 2, + 'content_version' => 1, + 'name' => 'dva', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 2, + 'content_version' => 1, + 'name' => 'zwei', + 'content_translation' => 'ger-DE', + ], + 2 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'jedan', + 'content_translation' => 'cro-HR', + ], + 3 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'one', + 'content_translation' => 'eng-GB', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_simple.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_simple.php index eda3e633fd4..bb5891154d3 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_simple.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_simple.php @@ -167,10 +167,38 @@ 0 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 4, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap hr', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap en', + 'content_translation' => 'eng-GB', + ], + 2 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap hr', + 'content_translation' => 'cro-HR', + ], + 3 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap en', + 'content_translation' => 'eng-GB', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_path_identification_string.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_path_identification_string.php index f8db85eb12b..f3f86ea830e 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_path_identification_string.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_path_identification_string.php @@ -106,10 +106,26 @@ 0 => array( 'id' => 2, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 2, + 'content_version' => 1, + 'name' => 'dva', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'jedan', + 'content_translation' => 'cro-HR', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_external_history.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_external_history.php index ba2186e4841..319bc894d64 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_external_history.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_external_history.php @@ -199,10 +199,26 @@ 0 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 4, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap that', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap this', + 'content_translation' => 'cro-HR', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_nop.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_nop.php index 6044729c609..50f186e7567 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_nop.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_nop.php @@ -167,10 +167,26 @@ 0 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 4, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap that', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap this', + 'content_translation' => 'cro-HR', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name.php new file mode 100644 index 00000000000..c8800b5773b --- /dev/null +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name.php @@ -0,0 +1,119 @@ + [ + 0 => [ + 'action' => 'eznode:2', + 'action_type' => 'eznode', + 'alias_redirects' => '1', + 'id' => '1', + 'is_alias' => '0', + 'is_original' => '1', + 'lang_mask' => '3', + 'link' => '1', + 'parent' => '0', + 'text' => '', + 'text_md5' => 'd41d8cd98f00b204e9800998ecf8427e', + ], + 1 => [ + 'action' => 'eznode:314', + 'action_type' => 'eznode', + 'alias_redirects' => '1', + 'id' => '2', + 'is_alias' => '0', + 'is_original' => '1', + 'lang_mask' => '2', + 'link' => '2', + 'parent' => '0', + 'text' => 'swap', + 'text_md5' => 'f0a1dfdc675b0a14a64099f7ac1cee83', + ], + 2 => [ + 'action' => 'eznode:315', + 'action_type' => 'eznode', + 'alias_redirects' => '1', + 'id' => '3', + 'is_alias' => '0', + 'is_original' => '1', + 'lang_mask' => '2', + 'link' => '3', + 'parent' => '0', + 'text' => 'swap2', + 'text_md5' => '83ec7c6c8809feb76d8a46d0aad18f0f', + ], + ], + 'ezcontent_language' => [ + 0 => [ + 'disabled' => 0, + 'id' => 2, + 'locale' => 'cro-HR', + 'name' => 'Croatian (Hrvatski)', + ], + ], + 'ezurlalias_ml_incr' => [ + 0 => [ + 'id' => '1', + ], + 1 => [ + 'id' => '2', + ], + 2 => [ + 'id' => '3', + ], + ], + 'ezcontentobject_tree' => [ + 0 => [ + 'node_id' => 2, + 'main_node_id' => 2, + 'parent_node_id' => 1, + 'path_string' => '', + 'path_identification_string' => '', + 'remote_id' => '', + 'contentobject_id' => 1, + ], + 1 => [ + 'node_id' => 314, + 'main_node_id' => 314, + 'parent_node_id' => 2, + 'path_string' => '', + 'path_identification_string' => '', + 'remote_id' => '', + 'contentobject_id' => 2, + ], + 2 => [ + 'node_id' => 315, + 'main_node_id' => 315, + 'parent_node_id' => 2, + 'path_string' => '', + 'path_identification_string' => '', + 'remote_id' => '', + 'contentobject_id' => 3, + ], + ], + 'ezcontentobject' => [ + 0 => [ + 'id' => 2, + 'initial_language_id' => 2, + 'current_version' => 1, + ], + 1 => [ + 'id' => 3, + 'initial_language_id' => 2, + 'current_version' => 1, + ], + ], + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 2, + 'content_version' => 1, + 'name' => 'swap', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap', + 'content_translation' => 'cro-HR', + ], + ], +]; diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name_multilang.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name_multilang.php new file mode 100644 index 00000000000..3e7ee93403c --- /dev/null +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name_multilang.php @@ -0,0 +1,163 @@ + [ + 0 => [ + 'action' => 'eznode:2', + 'action_type' => 'eznode', + 'alias_redirects' => '1', + 'id' => '1', + 'is_alias' => '0', + 'is_original' => '1', + 'lang_mask' => '3', + 'link' => '1', + 'parent' => '0', + 'text' => '', + 'text_md5' => 'd41d8cd98f00b204e9800998ecf8427e', + ], + 1 => [ + 'action' => 'eznode:314', + 'action_type' => 'eznode', + 'alias_redirects' => '1', + 'id' => '2', + 'is_alias' => '0', + 'is_original' => '1', + 'lang_mask' => '2', + 'link' => '2', + 'parent' => '0', + 'text' => 'swap-hr', + 'text_md5' => 'b0a33436ea51b6cc92f20b7d5be52cf6', + ], + 2 => [ + 'action' => 'eznode:314', + 'action_type' => 'eznode', + 'alias_redirects' => '1', + 'id' => '2', + 'is_alias' => '0', + 'is_original' => '1', + 'lang_mask' => '4', + 'link' => '2', + 'parent' => '0', + 'text' => 'swap-en2', + 'text_md5' => '75d19c821c6535b5e038219f07dbb03b', + ], + 3 => [ + 'action' => 'eznode:315', + 'action_type' => 'eznode', + 'alias_redirects' => '1', + 'id' => '3', + 'is_alias' => '0', + 'is_original' => '1', + 'lang_mask' => '2', + 'link' => '3', + 'parent' => '0', + 'text' => 'swap-hr2', + 'text_md5' => '176417c6cd9900cd485342858b8e3efa', + ], + 4 => [ + 'action' => 'eznode:315', + 'action_type' => 'eznode', + 'alias_redirects' => '1', + 'id' => '3', + 'is_alias' => '0', + 'is_original' => '1', + 'lang_mask' => '4', + 'link' => '3', + 'parent' => '0', + 'text' => 'swap-en', + 'text_md5' => '5a1cafd1fc29c227c11c751d79b0c155', + ], + ], + 'ezcontent_language' => [ + 0 => [ + 'disabled' => 0, + 'id' => 2, + 'locale' => 'cro-HR', + 'name' => 'Croatian (Hrvatski)', + ], + 1 => [ + 'disabled' => 0, + 'id' => 4, + 'locale' => 'eng-GB', + 'name' => 'English (United Kingdom)', + ], + ], + 'ezurlalias_ml_incr' => [ + 0 => [ + 'id' => '1', + ], + 1 => [ + 'id' => '2', + ], + 2 => [ + 'id' => '3', + ], + ], + 'ezcontentobject_tree' => [ + 0 => [ + 'node_id' => 2, + 'main_node_id' => 2, + 'parent_node_id' => 1, + 'path_string' => '', + 'path_identification_string' => '', + 'remote_id' => '', + 'contentobject_id' => 1, + ], + 1 => [ + 'node_id' => 314, + 'main_node_id' => 314, + 'parent_node_id' => 2, + 'path_string' => '', + 'path_identification_string' => '', + 'remote_id' => '', + 'contentobject_id' => 2, + ], + 2 => [ + 'node_id' => 315, + 'main_node_id' => 315, + 'parent_node_id' => 2, + 'path_string' => '', + 'path_identification_string' => '', + 'remote_id' => '', + 'contentobject_id' => 3, + ], + ], + 'ezcontentobject' => [ + 0 => [ + 'id' => 2, + 'initial_language_id' => 2, + 'current_version' => 1, + ], + 1 => [ + 'id' => 3, + 'initial_language_id' => 2, + 'current_version' => 1, + ], + ], + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 2, + 'content_version' => 1, + 'name' => 'swap hr', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 2, + 'content_version' => 1, + 'name' => 'swap en', + 'content_translation' => 'eng-GB', + ], + 2 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap hr', + 'content_translation' => 'cro-HR', + ], + 3 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap en', + 'content_translation' => 'eng-GB', + ], + ], +]; diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple.php index 4e11915ce97..946e80663bb 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple.php @@ -94,10 +94,26 @@ 0 => array( 'id' => 2, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 2, + 'content_version' => 1, + 'name' => 'dva', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'jedan', + 'content_translation' => 'cro-HR', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple_history.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple_history.php index 0794eb00414..76a3c95e0e4 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple_history.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple_history.php @@ -126,10 +126,26 @@ 0 => array( 'id' => 2, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 2, + 'content_version' => 1, + 'name' => 'dva new', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'jedan new', + 'content_translation' => 'cro-HR', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple.php index ce9c9d9c287..2672d811849 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple.php @@ -135,10 +135,26 @@ 0 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 4, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap', + 'content_translation' => 'cro-HR', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple_conflict.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple_conflict.php index 08ddbe7dc4e..3b2c60d253c 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple_conflict.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple_conflict.php @@ -193,10 +193,26 @@ 0 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 4, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap new 2', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap new 1', + 'content_translation' => 'cro-HR', + ], + ], ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple_history.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple_history.php index 1674ff2cb0c..165b529c202 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple_history.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/_fixtures/urlaliases_swap_simple_history.php @@ -167,10 +167,26 @@ 0 => array( 'id' => 3, 'initial_language_id' => 2, + 'current_version' => 1, ), 1 => array( 'id' => 4, 'initial_language_id' => 2, + 'current_version' => 1, ), ), + 'ezcontentobject_name' => [ + 0 => [ + 'contentobject_id' => 3, + 'content_version' => 1, + 'name' => 'swap new', + 'content_translation' => 'cro-HR', + ], + 1 => [ + 'contentobject_id' => 4, + 'content_version' => 1, + 'name' => 'swap new', + 'content_translation' => 'cro-HR', + ], + ], ); diff --git a/eZ/Publish/Core/settings/storage_engines/legacy/url_alias.yml b/eZ/Publish/Core/settings/storage_engines/legacy/url_alias.yml index fea0ba64f67..1075ea02746 100644 --- a/eZ/Publish/Core/settings/storage_engines/legacy/url_alias.yml +++ b/eZ/Publish/Core/settings/storage_engines/legacy/url_alias.yml @@ -33,4 +33,6 @@ services: - "@ezpublish.persistence.legacy.location.gateway" - "@ezpublish.spi.persistence.legacy.language.handler" - "@ezpublish.persistence.slug_converter" + - "@ezpublish.persistence.legacy.content.gateway" + - "@ezpublish.persistence.legacy.language.mask_generator" lazy: true