[BUGFIX] Make DataHandler aware of relations behind special=languages 35/46535/3
authorMarkus Klein <markus.klein@typo3.org>
Mon, 8 Feb 2016 16:43:58 +0000 (17:43 +0100)
committerAndreas Wolf <andreas.wolf@typo3.org>
Mon, 7 Mar 2016 12:21:35 +0000 (13:21 +0100)
The special TCA option "languages" makes some other TCA options like
foreign_table unnecessary which have been removed from
the sys_language_uid fields.

But DataHandler relies on the 'foreign_table' setting and therefore
needs some more information to resolve the related table
behind the "languages" option.

Resolves: #73182
Releases: master, 7.6
Change-Id: Id8f7f995d424f69fd5dce8e28cb1fc9db33fa0b0
Reviewed-on: https://review.typo3.org/46535
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/core/Classes/DataHandling/DataHandler.php

index 3ec0c8a..3b3a37d 100644 (file)
@@ -1979,7 +1979,7 @@ class DataHandler
         }
         // For select types which has a foreign table attached:
         $unsetResult = false;
-        if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['foreign_table']) {
+        if ($tcaFieldConf['type'] === 'select' && ($tcaFieldConf['foreign_table'] || isset($tcaFieldConf['special']) && $tcaFieldConf['special'] === 'languages')) {
             // check, if there is a NEW... id in the value, that should be substituted later
             if (strpos($value, 'NEW') !== false) {
                 $this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack));
@@ -2804,7 +2804,13 @@ class DataHandler
      */
     public function checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, $type, $currentTable, $currentField)
     {
-        $tables = $type == 'group' ? $tcaFieldConf['allowed'] : $tcaFieldConf['foreign_table'];
+        if ($type === 'group') {
+            $tables = $tcaFieldConf['allowed'];
+        } elseif (!empty($tcaFieldConf['special']) && $tcaFieldConf['special'] === 'languages') {
+            $tables = 'sys_language';
+        } else {
+            $tables = $tcaFieldConf['foreign_table'];
+        }
         $prep = $type == 'group' ? $tcaFieldConf['prepend_tname'] : '';
         $newRelations = implode(',', $valueArray);
         /** @var $dbAnalysis RelationHandler */