Skip to content

Commit

Permalink
IBX-8562: Fixed flooding content attributes table with duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattfarinn committed Jul 24, 2024
1 parent b195745 commit 18b7369
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions eZ/Publish/Core/Persistence/Legacy/Content/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ public function load($id, $version = null, array $translations = null)
$this->contentGateway->loadVersionedNameData([[
'id' => $id,
'version' => $rows[0]['ezcontentobject_version_version'],
]])
]]),
'ezcontentobject_',
$translations
);
$content = $contentObjects[0];
unset($rows, $contentObjects);
Expand Down Expand Up @@ -371,7 +373,9 @@ public function loadContentList(array $contentIds, array $translations = null):
try {
$contentList = $this->mapper->extractContentFromRows(
$contentItemsRow,
$contentItemNameData[$contentId]
$contentItemNameData[$contentId],
'ezcontentobject_',
$translations
);
$contentItems[$contentId] = $contentList[0];
} catch (Exception $e) {
Expand Down
13 changes: 9 additions & 4 deletions eZ/Publish/Core/Persistence/Legacy/Content/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public function convertToStorageValue(Field $field)
* @param array<array<string, scalar>> $rows
* @param array<array<string, scalar>> $nameRows
* @param string $prefix
* @param array<string>|null $translations
*
* @return \eZ\Publish\SPI\Persistence\Content[]
*
Expand All @@ -228,7 +229,8 @@ public function convertToStorageValue(Field $field)
public function extractContentFromRows(
array $rows,
array $nameRows,
string $prefix = 'ezcontentobject_'
string $prefix = 'ezcontentobject_',
?array $translations = null
): array {
$versionedNameData = [];

Expand All @@ -245,7 +247,8 @@ public function extractContentFromRows(

$fieldDefinitions = $this->loadCachedVersionFieldDefinitionsPerLanguage(
$rows,
$prefix
$prefix,
$translations
);

foreach ($rows as $row) {
Expand Down Expand Up @@ -348,7 +351,8 @@ private function buildContentObjects(
*/
private function loadCachedVersionFieldDefinitionsPerLanguage(
array $rows,
string $prefix
string $prefix,
?array $translations = null
): array {
$fieldDefinitions = [];
$contentTypes = [];
Expand All @@ -364,7 +368,8 @@ private function loadCachedVersionFieldDefinitionsPerLanguage(
continue;
}

$languageCodes = $this->extractLanguageCodesFromMask($languageMask, $allLanguages);
$allLanguagesCodes = $this->extractLanguageCodesFromMask($languageMask, $allLanguages);
$languageCodes = empty($translations) ? $allLanguagesCodes : array_intersect($translations, $allLanguagesCodes);
$contentTypes[$contentTypeId] = $contentTypes[$contentTypeId] ?? $this->contentTypeHandler->load($contentTypeId);
$contentType = $contentTypes[$contentTypeId];
foreach ($contentType->fieldDefinitions as $fieldDefinition) {
Expand Down

0 comments on commit 18b7369

Please sign in to comment.