[BUGFIX] Faulty localization if IRRE is used on pages
authorOliver Hader <oliver@typo3.org>
Fri, 12 Oct 2012 13:18:04 +0000 (15:18 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 17 Oct 2012 09:16:06 +0000 (11:16 +0200)
Due to the fact that the pages table has it's own translation
table, pages_language_overlay, localization of IRRE records is
not possible there.
The fix is to use the TCA setting transOrigPointerTable
(= pages_language_overlay) instead of the original parent table
(= pages).

Change-Id: I088fe01033f9cf9c35a0e979215bb378be4a3dba
Fixes: #41924
Releases: 4.5, 4.6, 4.7, 6.0
Reviewed-on: http://review.typo3.org/15523
Reviewed-by: Steffen Ritter
Reviewed-by: Georg Ringer
Tested-by: Steffen Ritter
Reviewed-by: Andreas Wolf
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/backend/Classes/Form/Element/InlineElement.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Database/RelationHandler.php

index 9423748..fadca69 100644 (file)
@@ -1116,7 +1116,7 @@ class InlineElement {
                        $parentRecord = $this->getRecord(0, $parent['table'], $parent['uid']);
                        $cmd = array();
                        $cmd[$parent['table']][$parent['uid']]['inlineLocalizeSynchronize'] = $parent['field'] . ',' . $type;
-                       /** @var \TYPO3\CMS\Core\DataHandling\DataHandler */
+                       /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
                        $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
                        $tce->stripslashes_values = FALSE;
                        $tce->start(array(), $cmd);
@@ -1286,7 +1286,6 @@ class InlineElement {
         * @todo Define visibility
         */
        public function getRelatedRecords($table, $field, $row, &$PA, $config) {
-               $records = array();
                $pid = $row['pid'];
                $elements = $PA['itemFormElValue'];
                $foreignTable = $config['foreign_table'];
@@ -1294,14 +1293,16 @@ class InlineElement {
                if ($localizationMode != FALSE) {
                        $language = intval($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
                        $transOrigPointer = intval($row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]);
+                       $transOrigTable = \TYPO3\CMS\Backend\Utility\BackendUtility::getOriginalTranslationTable($table);
+
                        if ($language > 0 && $transOrigPointer) {
                                // Localization in mode 'keep', isn't a real localization, but keeps the children of the original parent record:
                                if ($localizationMode == 'keep') {
-                                       $transOrigRec = $this->getRecord(0, $table, $transOrigPointer);
+                                       $transOrigRec = $this->getRecord(0, $transOrigTable, $transOrigPointer);
                                        $elements = $transOrigRec[$field];
                                        $pid = $transOrigRec['pid'];
                                } elseif ($localizationMode == 'select') {
-                                       $transOrigRec = $this->getRecord(0, $table, $transOrigPointer);
+                                       $transOrigRec = $this->getRecord(0, $transOrigTable, $transOrigPointer);
                                        $pid = $transOrigRec['pid'];
                                        $recordsOriginal = $this->getRelatedRecordsArray($pid, $foreignTable, $transOrigRec[$field]);
                                }
index eb2a868..6cdd03b 100644 (file)
@@ -576,6 +576,21 @@ class BackendUtility {
        }
 
        /**
+        * Gets the original translation pointer table.
+        * For e.g. pages_language_overlay this would be pages.
+        *
+        * @param string $table Name of the table
+        * @return string Pointer table (if any)
+        */
+       static public function getOriginalTranslationTable($table) {
+               if (!empty($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
+                       $table = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
+               }
+
+               return $table;
+       }
+
+       /**
         * Determines whether a table is localizable and has the languageField and transOrigPointerField set in $GLOBALS['TCA'].
         *
         * @param string $table The table to check
index 291e450..1862a76 100644 (file)
@@ -3837,17 +3837,20 @@ class DataHandler {
                                $parentRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, $id);
                                $language = intval($parentRecord[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
                                $transOrigPointer = intval($parentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]);
+                               $transOrigTable = \TYPO3\CMS\Backend\Utility\BackendUtility::getOriginalTranslationTable($table);
                                $childTransOrigPointerField = $GLOBALS['TCA'][$foreignTable]['ctrl']['transOrigPointerField'];
+
                                if ($parentRecord && is_array($parentRecord) && $language > 0 && $transOrigPointer) {
                                        $inlineSubType = $this->getInlineFieldType($config);
-                                       $transOrigRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, $transOrigPointer);
+                                       $transOrigRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($transOrigTable, $transOrigPointer);
+
                                        if ($inlineSubType !== FALSE) {
                                                $removeArray = array();
                                                $mmTable = $inlineSubType == 'mm' && isset($config['MM']) && $config['MM'] ? $config['MM'] : '';
                                                // Fetch children from original language parent:
                                                /** @var $dbAnalysisOriginal \TYPO3\CMS\Core\Database\RelationHandler */
                                                $dbAnalysisOriginal = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
-                                               $dbAnalysisOriginal->start($transOrigRecord[$field], $foreignTable, $mmTable, $transOrigRecord['uid'], $table, $config);
+                                               $dbAnalysisOriginal->start($transOrigRecord[$field], $foreignTable, $mmTable, $transOrigRecord['uid'], $transOrigTable, $config);
                                                $elementsOriginal = array();
                                                foreach ($dbAnalysisOriginal->itemArray as $item) {
                                                        $elementsOriginal[$item['id']] = $item;
index a4f5b24..4e49e95 100644 (file)
@@ -590,7 +590,6 @@ class RelationHandler {
        public function readForeignField($uid, $conf) {
                $key = 0;
                $uid = intval($uid);
-               $whereClause = '';
                $foreign_table = $conf['foreign_table'];
                $foreign_table_field = $conf['foreign_table_field'];
                $useDeleteClause = $this->undeleteRecord ? FALSE : TRUE;