[TASK] Improve updates of metadata in MetaDataRepository 70/25470/4
authorNicole Cordes <typo3@cordes.co>
Sun, 17 Nov 2013 00:06:07 +0000 (01:06 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 19 Nov 2013 21:49:56 +0000 (22:49 +0100)
If you run the FAL update wizard for tt_content images the
MetaDataRepository requests database fields for each update separately.
This information should be stored in an internal array to avoid
unnecessary database requests and increase performance.

Resolves: #53709
Releases: 6.2
Change-Id: Icbef451f9a02395d758626254be004e87f350039
Reviewed-on: https://review.typo3.org/25470
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Classes/Resource/Index/MetaDataRepository.php

index 8a6a3c1..547de47 100644 (file)
@@ -45,6 +45,13 @@ class MetaDataRepository implements SingletonInterface {
        protected $tableName = 'sys_file_metadata';
 
        /**
+        * Internal storage for database table fields
+        *
+        * @var array
+        */
+       protected $tableFields = array();
+
+       /**
         * Wrapper method for getting DatabaseConnection
         *
         * @return \TYPO3\CMS\Core\Database\DatabaseConnection
@@ -123,12 +130,16 @@ class MetaDataRepository implements SingletonInterface {
        /**
         * Updates the metadata record in the database
         *
-        * @internal
         * @param int $fileUid the file uid to update
         * @param array $data Data to update
+        * @return void
+        * @internal
         */
        public function update($fileUid, array $data) {
-               $updateRow = array_intersect_key($data, $this->getDatabase()->admin_get_fields($this->tableName));
+               if (count($this->tableFields) === 0) {
+                       $this->tableFields = $this->getDatabase()->admin_get_fields($this->tableName);
+               }
+               $updateRow = array_intersect_key($data, $this->tableFields);
                if (array_key_exists('uid', $updateRow)) {
                        unset($updateRow['uid']);
                }