[TASK] Add hashcolumn to field configuration of sys_file_processedfile 34/24734/5
authorGeorg Ringer <georg.ringer@gmail.com>
Mon, 14 Oct 2013 11:14:06 +0000 (13:14 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 10 Nov 2013 13:49:42 +0000 (14:49 +0100)
Because of perfomance reason it would be good to have a hash column for
the field configuration of the table sys_file_processedfile.

Change-Id: I310428afff335217afaa77f1a2ee6d628c80e8ef
Resolves: #52788
Releases: 6.2
Reviewed-on: https://review.typo3.org/24734
Reviewed-by: Sebastian Fischer
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Kai Ole Hartwig
Tested-by: Kai Ole Hartwig
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Classes/Resource/ProcessedFile.php
typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php
typo3/sysext/core/ext_tables.sql
typo3/sysext/install/Classes/Updates/TruncateSysFileProcessedFileTable.php [new file with mode: 0644]
typo3/sysext/install/ext_localconf.php

index 52c1f17..cbca775 100644 (file)
@@ -357,11 +357,13 @@ class ProcessedFile extends AbstractFile {
                        $properties['name'] = $this->getName();
                }
 
+               $properties['configuration'] = serialize($this->processingConfiguration);
+
                return array_merge($properties, array(
                        'storage' => $this->getStorage()->getUid(),
                        'checksum' => $this->calculateChecksum(),
                        'task_type' => $this->taskType,
-                       'configuration' => serialize($this->processingConfiguration),
+                       'configurationsha1' => sha1($properties['configuration']),
                        'original' => $this->originalFile->getUid(),
                        'originalfilesha1' => $this->originalFileSha1
                ));
index 85f9104..e3d5b99 100644 (file)
@@ -154,7 +154,7 @@ class ProcessedFileRepository extends AbstractRepository {
                        $this->table,
                        'original=' . intval($file->getUid()) .
                                ' AND task_type=' . $this->databaseConnection->fullQuoteStr($taskType, $this->table) .
-                               ' AND configuration=' . $this->databaseConnection->fullQuoteStr(serialize($configuration), $this->table)
+                               ' AND configurationsha1=' . $this->databaseConnection->fullQuoteStr(sha1(serialize($configuration)), $this->table)
                );
 
                if (is_array($databaseRow)) {
index c2340f9..035ae94 100644 (file)
@@ -362,6 +362,7 @@ CREATE TABLE sys_file_processedfile (
        identifier varchar(512) DEFAULT '' NOT NULL,
        name tinytext,
        configuration text,
+       configurationsha1 varchar(40) DEFAULT '' NOT NULL,
        originalfilesha1 varchar(40) DEFAULT '' NOT NULL,
        task_type varchar(200) DEFAULT '' NOT NULL,
        checksum varchar(255) DEFAULT '' NOT NULL,
diff --git a/typo3/sysext/install/Classes/Updates/TruncateSysFileProcessedFileTable.php b/typo3/sysext/install/Classes/Updates/TruncateSysFileProcessedFileTable.php
new file mode 100644 (file)
index 0000000..ed7c285
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+namespace TYPO3\CMS\Install\Updates;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Wouter Wolters <typo3@wouterwolters.nl>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Upgrade wizard which will truncate the sys_file_processedfile table
+ */
+class TruncateSysFileProcessedFileTable extends AbstractUpdate {
+
+       /**
+        * @var string
+        */
+       protected $title = 'Truncate all processed files to clean up obsolete records.';
+
+       /**
+        * Checks whether updates are required.
+        *
+        * @param string &$description The description for the update
+        * @return boolean Whether an update is required (TRUE) or not (FALSE)
+        */
+       public function checkForUpdate(&$description) {
+               if ($this->isWizardDone() || !$this->checkIfTableExists('sys_file_processedfile')) {
+                       return FALSE;
+               }
+
+               $description = 'To re-process all files correctly we truncate the table. This will make sure there are no obsolete files in the database.';
+               return TRUE;
+       }
+
+       /**
+        * Performs the accordant updates.
+        *
+        * @param array &$databaseQueries Queries done in this update
+        * @param mixed &$customMessages Custom messages
+        * @return boolean Whether everything went smoothly or not
+        */
+       public function performUpdate(array &$databaseQueries, &$customMessages) {
+               $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('sys_file_processedfile');
+               $databaseQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
+               $this->markWizardAsDone();
+               return TRUE;
+       }
+
+}
+?>
\ No newline at end of file
index 0558aec..7a851ac 100644 (file)
@@ -42,6 +42,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['sysext_file_
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['sysext_file_images'] = 'TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard';
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['sysext_file_uploads'] = 'TYPO3\\CMS\\Install\\Updates\\TtContentUploadsUpdateWizard';
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['sysext_file_splitMetaData'] = 'TYPO3\\CMS\\Install\\Updates\\FileTableSplittingUpdate';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['sysext_file_truncateProcessedFileTable'] = 'TYPO3\\CMS\\Install\\Updates\\TruncateSysFileProcessedFileTable';
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['referenceIntegrity'] = 'TYPO3\\CMS\\Install\\Updates\\ReferenceIntegrityUpdateWizard';
 
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['sysext_file_filemounts'] = 'TYPO3\\CMS\\Install\\Updates\\FilemountUpdateWizard';