[BUGFIX] Better caching of TCA for bulk inserts
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Utility / BackendUtility.php
index 795b464..3084cbc 100644 (file)
@@ -39,6 +39,14 @@ use TYPO3\CMS\Frontend\Page\PageRepository;
  */
 class BackendUtility {
 
+       /**
+        * Cache the TCA configuration of tables with their types during runtime
+        *
+        * @var array
+        * @see getTCAtypes()
+        */
+       static protected $tcaTableTypeConfigurationCache = array();
+
        /*******************************************
         *
         * SQL-related, selecting records, searching
@@ -712,6 +720,13 @@ class BackendUtility {
                if ($GLOBALS['TCA'][$table]) {
                        // Get type value:
                        $fieldValue = self::getTCAtypeValue($table, $rec);
+                       $cacheIdentifier = $table . '-type-' . $fieldValue . '-fnk-' . $useFieldNameAsKey;
+
+                       // Fetch from first-level-cache if available
+                       if (isset(self::$tcaTableTypeConfigurationCache[$cacheIdentifier])) {
+                               return self::$tcaTableTypeConfigurationCache[$cacheIdentifier];
+                       }
+
                        // Get typesConf
                        $typesConf = $GLOBALS['TCA'][$table]['types'][$fieldValue];
                        // Get fields list and traverse it
@@ -747,6 +762,10 @@ class BackendUtility {
                        if ($useFieldNameAsKey) {
                                $fieldList = $altFieldList;
                        }
+
+                       // Add to first-level-cache
+                       self::$tcaTableTypeConfigurationCache[$cacheIdentifier] = $fieldList;
+
                        // Return array:
                        return $fieldList;
                }