[BUGFIX] Make DataHandler aware of relations behind special=languages 68/48468/2
authorMarkus Klein <markus.klein@typo3.org>
Mon, 8 Feb 2016 16:43:58 +0000 (17:43 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Mon, 6 Jun 2016 19:37:57 +0000 (21:37 +0200)
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/48468
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Classes/DataHandling/DataHandler.php

index cdee8dd..eafa478 100644 (file)
@@ -2117,7 +2117,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));
@@ -2963,7 +2963,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 */