Skip to content

Commit 18b7369

Browse files
committed
IBX-8562: Fixed flooding content attributes table with duplicates
1 parent b195745 commit 18b7369

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

eZ/Publish/Core/Persistence/Legacy/Content/Handler.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ public function load($id, $version = null, array $translations = null)
320320
$this->contentGateway->loadVersionedNameData([[
321321
'id' => $id,
322322
'version' => $rows[0]['ezcontentobject_version_version'],
323-
]])
323+
]]),
324+
'ezcontentobject_',
325+
$translations
324326
);
325327
$content = $contentObjects[0];
326328
unset($rows, $contentObjects);
@@ -371,7 +373,9 @@ public function loadContentList(array $contentIds, array $translations = null):
371373
try {
372374
$contentList = $this->mapper->extractContentFromRows(
373375
$contentItemsRow,
374-
$contentItemNameData[$contentId]
376+
$contentItemNameData[$contentId],
377+
'ezcontentobject_',
378+
$translations
375379
);
376380
$contentItems[$contentId] = $contentList[0];
377381
} catch (Exception $e) {

eZ/Publish/Core/Persistence/Legacy/Content/Mapper.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ public function convertToStorageValue(Field $field)
220220
* @param array<array<string, scalar>> $rows
221221
* @param array<array<string, scalar>> $nameRows
222222
* @param string $prefix
223+
* @param array<string>|null $translations
223224
*
224225
* @return \eZ\Publish\SPI\Persistence\Content[]
225226
*
@@ -228,7 +229,8 @@ public function convertToStorageValue(Field $field)
228229
public function extractContentFromRows(
229230
array $rows,
230231
array $nameRows,
231-
string $prefix = 'ezcontentobject_'
232+
string $prefix = 'ezcontentobject_',
233+
?array $translations = null
232234
): array {
233235
$versionedNameData = [];
234236

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

246248
$fieldDefinitions = $this->loadCachedVersionFieldDefinitionsPerLanguage(
247249
$rows,
248-
$prefix
250+
$prefix,
251+
$translations
249252
);
250253

251254
foreach ($rows as $row) {
@@ -348,7 +351,8 @@ private function buildContentObjects(
348351
*/
349352
private function loadCachedVersionFieldDefinitionsPerLanguage(
350353
array $rows,
351-
string $prefix
354+
string $prefix,
355+
?array $translations = null
352356
): array {
353357
$fieldDefinitions = [];
354358
$contentTypes = [];
@@ -364,7 +368,8 @@ private function loadCachedVersionFieldDefinitionsPerLanguage(
364368
continue;
365369
}
366370

367-
$languageCodes = $this->extractLanguageCodesFromMask($languageMask, $allLanguages);
371+
$allLanguagesCodes = $this->extractLanguageCodesFromMask($languageMask, $allLanguages);
372+
$languageCodes = empty($translations) ? $allLanguagesCodes : array_intersect($translations, $allLanguagesCodes);
368373
$contentTypes[$contentTypeId] = $contentTypes[$contentTypeId] ?? $this->contentTypeHandler->load($contentTypeId);
369374
$contentType = $contentTypes[$contentTypeId];
370375
foreach ($contentType->fieldDefinitions as $fieldDefinition) {

0 commit comments

Comments
 (0)