Commit b9f25d92 authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Christian Kuhn
Browse files

[BUGFIX] Respect TCA type language in getProcessedValue

Since #57082 the language columns, typically
`sys_language_uid`, are defined with the new
TCA type "language" instead of type "select".

Since this was previously not properly handled,
BackendUtility::getProcessedValue() just returned
the records' field value instead of the language title.

This is now fixed by adding an additional "case" for
TCA type "language".

Resolves: #94610
Releases: master
Change-Id: I89297e679393cb8eb0765a51fb6a7eebc4e12f7c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70022

Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent d30ba9cf
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Utility;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
use TYPO3\CMS\Backend\Routing\Route;
use TYPO3\CMS\Backend\Routing\UriBuilder;
......@@ -1916,6 +1917,17 @@ class BackendUtility
case 'flex':
$l = strip_tags($value);
break;
case 'language':
$l = $value;
if ($uid) {
$pageId = (int)($table === 'pages' ? $uid : (static::getRecordWSOL($table, (int)$uid, 'pid')['pid'] ?? 0));
$languageTitle = GeneralUtility::makeInstance(TranslationConfigurationProvider::class)
->getSystemLanguages($pageId)[(int)$value]['title'] ?? '';
if ($languageTitle !== '') {
$l = $languageTitle;
}
}
break;
default:
if ($defaultPassthrough) {
$l = $value;
......
......@@ -6,15 +6,26 @@ namespace TYPO3\CMS\Backend\Tests\Functional\Utility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class BackendUtilityTest extends FunctionalTestCase
{
use SiteBasedTestTrait;
protected const LANGUAGE_PRESETS = [
'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
'DK' => ['id' => 1, 'title' => 'Dansk', 'locale' => 'dk_DA.UTF8'],
'DE' => ['id' => 2, 'title' => 'German', 'locale' => 'de_DE.UTF8'],
];
public function setUp(): void
{
parent::setUp();
$this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml');
$this->setUpBackendUserFromFixture(1);
Bootstrap::initializeLanguageObject();
}
/**
......@@ -59,6 +70,50 @@ class BackendUtilityTest extends FunctionalTestCase
self::assertSame($expectedSiteHash, $actualSiteHash);
}
/**
* @test
*/
public function getProcessedValueForLanguage(): void
{
$this->writeSiteConfiguration(
'website-local',
$this->buildSiteConfiguration(1, 'http://localhost/'),
[
$this->buildDefaultLanguageConfiguration('EN', '/en/'),
$this->buildLanguageConfiguration('DK', '/dk/'),
$this->buildLanguageConfiguration('DE', '/de/'),
]
);
self::assertEquals(
'Dansk',
BackendUtility::getProcessedValue(
'pages',
'sys_language_uid',
1,
0,
false,
false,
1
)
);
$this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/tt_content.xml');
self::assertEquals(
'German',
BackendUtility::getProcessedValue(
'tt_content',
'sys_language_uid',
2,
0,
false,
false,
1
)
);
}
private function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
......
......@@ -87,7 +87,8 @@ class DownloadRecordListTest extends FunctionalTestCase
];
$subject = new DownloadRecordList($recordList, new TranslationConfigurationProvider());
$headerRow = $subject->getHeaderRow($recordList->setFields['pages']);
$contentRows = $subject->getRecords('pages', 1, $recordList->setFields['pages'], $this->user);
// Get records with raw values
$contentRows = $subject->getRecords('pages', 1, $recordList->setFields['pages'], $this->user, false, true);
$result = array_merge([$headerRow], $contentRows);
self::assertEquals([
[
......@@ -143,19 +144,19 @@ class DownloadRecordListTest extends FunctionalTestCase
'uid' => '2',
'pid' => '1',
'title' => 'Dummy 1-2',
'sys_language_uid' => '0'
'sys_language_uid' => 'Default'
],
[
'uid' => '3',
'pid' => '1',
'title' => 'Dummy 1-3',
'sys_language_uid' => '0'
'sys_language_uid' => 'Default'
],
[
'uid' => '4',
'pid' => '1',
'title' => 'Dummy 1-4',
'sys_language_uid' => '0'
'sys_language_uid' => 'Default'
]
], $this->prepareRecordsForDbCompatAssertions($result));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment