From f82848257822dbf21e823b2071f4fe12065c7fe5 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Fri, 23 Oct 2015 14:55:29 +0200 Subject: [PATCH] [BUGFIX] Remove getRecordTitle() runtime cache This reverts the runtime cache of BackendUtility::getRecordTitle() from commit d10070e81. This low level method is getting more and more unused anyway and is substituted with a data provider in FormEngine for example. The cache currently introduces issues in edge cases and the benefit of the cache in general in rather small. Resolves: #70435 Related: #69749 Releases: master Change-Id: Id9f352a2193f38fafc305001a2d20db16298b2fd Reviewed-on: https://review.typo3.org/44241 Reviewed-by: Jan Helke <typo3@helke.de> Tested-by: Jan Helke <typo3@helke.de> Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de> Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de> Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> --- .../Classes/Utility/BackendUtility.php | 14 ------------ .../Tests/Unit/Utility/BackendUtilityTest.php | 22 ------------------- 2 files changed, 36 deletions(-) diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index 35a713c5318c..1fc6e497513d 100755 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -60,14 +60,6 @@ class BackendUtility */ protected static $tcaTableTypeConfigurationCache = array(); - /** - * Cache the processed titles of records during runtime - * - * @var array - * @see self::getRecordTitle() - */ - protected static $recordTitleCache = array(); - /******************************************* * * SQL-related, selecting records, searching @@ -2165,11 +2157,6 @@ class BackendUtility */ public static function getRecordTitle($table, $row, $prep = false, $forceResult = true) { - $cacheIdentifier = $table . '-' . $row['uid'] . '-prep-' . (int)$prep . '-forceResult-' . (int)$forceResult; - if (isset(self::$recordTitleCache[$cacheIdentifier])) { - return self::$recordTitleCache[$cacheIdentifier]; - } - $recordTitle = ''; if (is_array($GLOBALS['TCA'][$table])) { // If configured, call userFunc @@ -2221,7 +2208,6 @@ class BackendUtility } } } - self::$recordTitleCache[$cacheIdentifier] = $recordTitle; return $recordTitle; } diff --git a/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php b/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php index 460d3c77ad46..360169cd8fac 100644 --- a/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php +++ b/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php @@ -1034,28 +1034,6 @@ class BackendUtilityTest extends UnitTestCase $this->assertSame($expected, $subject->_call('replaceL10nModeFields', $table, $row)); } - /** - * @test - */ - public function getRecordTitleHavingLabelUserFuncCachesValue() - { - $table = 'tx_mytable'; - $row = ['uid' => 1]; - - $mock = $this->getMock('stdClass', ['labelUserFunc']); - $mock->expects($this->once())->method('labelUserFunc')->willReturn('Test'); - - // Use wrapping closure for GeneralUtility::callUserFunction() - $GLOBALS['TCA'][$table]['ctrl']['label_userFunc'] = function (&$parameters) use ($mock) { - $parameters['title'] = $mock->labelUserFunc(); - }; - - $this->assertEquals('Test', BackendUtility::getRecordTitle($table, $row)); - - // Call a second time to make sure labelUserFunc is not called again ($this->once()) - $this->assertEquals('Test', BackendUtility::getRecordTitle($table, $row)); - } - /** * @test */ -- GitLab