diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index ba0d3c1d49a07aa6da543babcfcabfad69955daf..9e3693e6393e973c56b113c0928186fb00ad305e 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -1426,7 +1426,7 @@ class BackendUtility $recordTitle = self::getProcessedValue( $table, $ctrlLabel, - $row[$ctrlLabel] ?? '', + (string)($row[$ctrlLabel] ?? ''), 0, false, false, @@ -1434,7 +1434,7 @@ class BackendUtility $forceResult ) ?? ''; if (!empty($GLOBALS['TCA'][$table]['ctrl']['label_alt']) - && (!empty($GLOBALS['TCA'][$table]['ctrl']['label_alt_force']) || (string)$recordTitle === '') + && (!empty($GLOBALS['TCA'][$table]['ctrl']['label_alt_force']) || $recordTitle === '') ) { $altFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true); $tA = []; @@ -1442,8 +1442,8 @@ class BackendUtility $tA[] = $recordTitle; } foreach ($altFields as $fN) { - $recordTitle = trim(strip_tags($row[$fN] ?? '')); - if ((string)$recordTitle !== '') { + $recordTitle = trim(strip_tags((string)($row[$fN] ?? ''))); + if ($recordTitle !== '') { $recordTitle = self::getProcessedValue($table, $fN, $recordTitle, 0, false, false, $row['uid']); if (!($GLOBALS['TCA'][$table]['ctrl']['label_alt_force'] ?? false)) { break; diff --git a/typo3/sysext/backend/Tests/Functional/Utility/BackendUtilityTest.php b/typo3/sysext/backend/Tests/Functional/Utility/BackendUtilityTest.php index 536044163b947ec82481f05df05c26c5b59962fa..2ad8063cdc32a6bc35768055bd912fef9edbbfdb 100644 --- a/typo3/sysext/backend/Tests/Functional/Utility/BackendUtilityTest.php +++ b/typo3/sysext/backend/Tests/Functional/Utility/BackendUtilityTest.php @@ -24,6 +24,7 @@ class BackendUtilityTest extends FunctionalTestCase { parent::setUp(); $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml'); + $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/tt_content.xml'); $this->setUpBackendUserFromFixture(1); Bootstrap::initializeLanguageObject(); } @@ -98,8 +99,6 @@ class BackendUtilityTest extends FunctionalTestCase ) ); - $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/tt_content.xml'); - self::assertEquals( 'German', BackendUtility::getProcessedValue( @@ -114,6 +113,20 @@ class BackendUtilityTest extends FunctionalTestCase ); } + /** + * @test + */ + public function getRecordTitleForUidLabel(): void + { + $GLOBALS['TCA']['tt_content']['ctrl']['label'] = 'uid'; + unset($GLOBALS['TCA']['tt_content']['ctrl']['label_alt']); + + self::assertEquals( + '1', + BackendUtility::getRecordTitle('tt_content', BackendUtility::getRecord('tt_content', 1)) + ); + } + private function getBackendUser(): BackendUserAuthentication { return $GLOBALS['BE_USER'];