diff --git a/typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php b/typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php index dd63afc66b06d8b41797185d3545055d32d2d0fa..9443c98a2f64fdda388de17446dc83ec52b17475 100644 --- a/typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php +++ b/typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php @@ -41,6 +41,14 @@ class ProcessedFileRepository extends AbstractRepository */ protected $table = 'sys_file_processedfile'; + /** + * As determining the table columns is a costly operation this is done only once during runtime and cached then + * + * @var array + * @see cleanUnavailableColumns() + */ + protected $tableColumns = []; + /** * Creates this object. */ @@ -291,11 +299,15 @@ class ProcessedFileRepository extends AbstractRepository */ protected function cleanUnavailableColumns(array $data) { - $tableColumns = GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable($this->table) - ->getSchemaManager() - ->listTableColumns($this->table); - return array_intersect_key($data, $tableColumns); + // As determining the table columns is a costly operation this is done only once during runtime and cached then + if (empty($this->tableColumns[$this->table])) { + $this->tableColumns[$this->table] = GeneralUtility::makeInstance(ConnectionPool::class) + ->getConnectionForTable($this->table) + ->getSchemaManager() + ->listTableColumns($this->table); + } + + return array_intersect_key($data, $this->tableColumns[$this->table]); } /** diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php index a7457a3aed906485cd19f0078066e53b256bb8f9..e7c22579b57f486e7572725ecf60bfd95a009917 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php @@ -78,6 +78,14 @@ class Typo3DbBackend implements BackendInterface, SingletonInterface */ protected $objectManager; + /** + * As determining the table columns is a costly operation this is done only once per table during runtime and cached then + * + * @var array + * @see clearPageCache() + */ + protected $hasPidColumn = []; + /** * @param \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper */ @@ -672,11 +680,17 @@ class Typo3DbBackend implements BackendInterface, SingletonInterface } $pageIdsToClear = []; $storagePage = null; - $columns = GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable($tableName) - ->getSchemaManager() - ->listTableColumns($tableName); - if (array_key_exists('pid', $columns)) { + + // As determining the table columns is a costly operation this is done only once per table during runtime and cached then + if (!isset($this->hasPidColumn[$tableName])) { + $columns = GeneralUtility::makeInstance(ConnectionPool::class) + ->getConnectionForTable($tableName) + ->getSchemaManager() + ->listTableColumns($tableName); + $this->hasPidColumn[$tableName] = array_key_exists('pid', $columns); + } + + if ($this->hasPidColumn[$tableName]) { $queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName); $queryBuilder->getRestrictions()->removeAll(); $result = $queryBuilder