From 1736bc8c1cab4af02f68574e6d0da8f5f0f36b13 Mon Sep 17 00:00:00 2001 From: Dan Untenzu Date: Thu, 13 Oct 2016 17:26:08 +0200 Subject: [PATCH] [DOC] Explain flux parent assignment for translations Refs #1176 --- Classes/Service/ContentService.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Classes/Service/ContentService.php b/Classes/Service/ContentService.php index 8bcdd97fe..63abd9db8 100644 --- a/Classes/Service/ContentService.php +++ b/Classes/Service/ContentService.php @@ -290,12 +290,18 @@ public function initializeRecord($id, array &$row, DataHandler $tceMain) { */ protected function initializeRecordByNewAndOldAndLanguageUids($row, $newUid, $oldUid, $newLanguageUid, $languageFieldName, DataHandler $tceMain) { if (0 < $newUid && 0 < $oldUid && 0 < $newLanguageUid) { + // Get the origin record of the current record to find out if it has any + // parameters we need to adapt in the current record. $oldRecord = $this->loadRecordFromDatabase($oldUid); if ($oldRecord[$languageFieldName] !== $newLanguageUid && $oldRecord['pid'] === $row['pid'] && MathUtility::canBeInterpretedAsInteger($oldRecord['tx_flux_parent']) && $oldRecord['tx_flux_parent'] > 0) { - // look for the translated version of the parent record indicated - // in this new, translated record. Below, we adjust the parent UID - // so it has the UID of the translated parent if one exists. - $translatedParents = (array) $this->workspacesAwareRecordService->get('tt_content', 'uid,sys_language_uid', "t3_origuid = '" . $oldRecord['tx_flux_parent'] . "'" . BackendUtility::deleteClause('tt_content')); + // If the origin record has a flux parent assigned, then look for the + // translated, very last version this parent record and, if any valid record was found, + // assign its UID as flux parent to the current record. + $translatedParents = (array) $this->workspacesAwareRecordService->get( + 'tt_content', + 'uid,sys_language_uid', + 't3_origuid=' . $oldRecord['tx_flux_parent'] . BackendUtility::deleteClause('tt_content') + ); foreach ($translatedParents as $translatedParent) { if ($translatedParent['sys_language_uid'] == $newLanguageUid) { // set $translatedParent to the right language ($newLanguageUid):