From adfa782288843e7c77a4c6341cbbe4f5a6787947 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Tue, 28 Nov 2017 12:06:00 +0100
Subject: [PATCH] Revert "[BUGFIX] Fix language of placeholder for relations"

This reverts commit 5be3ec134bf1186260e3172832e8c69dfd13913d.

Further issues popped up in the master patch.

Reverts: #75040
Releases: master
Change-Id: I8ed284060b9b8ef018f4097c772032e81e3e885b
Reviewed-on: https://review.typo3.org/54826
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../FormDataProvider/TcaInputPlaceholders.php | 58 -------------------
 1 file changed, 58 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInputPlaceholders.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInputPlaceholders.php
index bd220e4ca378..b3e932e95f69 100644
--- a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInputPlaceholders.php
+++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInputPlaceholders.php
@@ -14,11 +14,9 @@ namespace TYPO3\CMS\Backend\Form\FormDataProvider;
  * The TYPO3 project - inspiring people to share!
  */
 
-use Doctrine\DBAL\Connection;
 use TYPO3\CMS\Backend\Form\FormDataCompiler;
 use TYPO3\CMS\Backend\Form\FormDataGroup\TcaInputPlaceholderRecord;
 use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
-use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -121,18 +119,7 @@ class TcaInputPlaceholders implements FormDataProviderInterface
         }
 
         if (!empty($possibleUids) && !empty($fieldNameArray)) {
-            if (count($possibleUids) > 1
-                && !empty($GLOBALS['TCA'][$foreignTableName]['ctrl']['languageField'])
-                && isset($result['currentSysLanguage'])
-            ) {
-                $possibleUids = $this->getPossibleUidsByCurrentSysLanguage($possibleUids, $foreignTableName, $result['currentSysLanguage']);
-            }
             $relatedFormData = $this->getRelatedFormData($foreignTableName, $possibleUids[0], $fieldNameArray[0]);
-            if (!empty($GLOBALS['TCA'][$result['tableName']]['ctrl']['languageField'])
-                && (isset($result['databaseRow'][$GLOBALS['TCA'][$result['tableName']]['ctrl']['languageField']]))
-            ) {
-                $relatedFormData['currentSysLanguage'] = $result['databaseRow'][$GLOBALS['TCA'][$result['tableName']]['ctrl']['languageField']][0];
-            }
             $value = $this->getPlaceholderValue($fieldNameArray, $relatedFormData, $recursionLevel + 1);
         }
 
@@ -215,51 +202,6 @@ class TcaInputPlaceholders implements FormDataProviderInterface
         return $allowedTable;
     }
 
-    /**
-     * E.g. sys_file is not translatable, thus the uid of the translation of it's metadata has to be retrieved here.
-     *
-     * Get the uid of e.g. a file metadata entry for a given sys_language_uid and the possible translated data.
-     * If there is no translation available, return the uid of default language.
-     * If there is no value at all, return the "possible uids".
-     *
-     * @param array $possibleUids
-     * @param string $foreignTableName
-     * @param int $currentLanguage
-     * @return array
-     */
-    protected function getPossibleUidsByCurrentSysLanguage(array $possibleUids, $foreignTableName, $currentLanguage)
-    {
-        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($foreignTableName);
-        $newUids = $queryBuilder->select('uid')
-            ->from($foreignTableName)
-            ->where(
-                $queryBuilder->expr()->in(
-                    'uid',
-                    $queryBuilder->createNamedParameter($possibleUids, Connection::PARAM_INT_ARRAY)
-                ),
-                $queryBuilder->expr()->in(
-                    $GLOBALS['TCA'][$foreignTableName]['ctrl']['languageField'],
-                    $queryBuilder->createNamedParameter([$currentLanguage, 0], Connection::PARAM_INT_ARRAY)
-                )
-            )
-            ->orderBy($GLOBALS['TCA'][$foreignTableName]['ctrl']['languageField'], 'ASC')
-            ->setMaxResults(2)
-            ->execute()
-            ->fetchAll(\PDO::FETCH_NUM);
-
-        if (!empty($newUids)) {
-            // translation available
-            if (!empty($newUids[1])) {
-                return $newUids[1];
-            }
-
-            // no translation available, use default
-            return $newUids[0];
-        }
-
-        return $possibleUids;
-    }
-
     /**
      * @return LanguageService
      */
-- 
GitLab