[BUGFIX] Remove getRecordTitle() runtime cache 41/44241/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 23 Oct 2015 12:55:29 +0000 (14:55 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 24 Oct 2015 21:45:47 +0000 (23:45 +0200)
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>
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php

index 35a713c..1fc6e49 100755 (executable)
@@ -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;
     }
index 460d3c7..360169c 100644 (file)
@@ -1037,28 +1037,6 @@ class BackendUtilityTest extends UnitTestCase
     /**
      * @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
-     */
     public function getSpecConfPartsSplitsDefaultExtras()
     {
         $defaultExtras = 'nowrap:wizards[foo|bar]:anotherDefaultExtras:some[other|setting|with|parameters]';