[TASK] Remove internal sys_history cleanup feature
authorStefan Galinski <stefan.galinski@gmail.com>
Wed, 27 Jun 2012 14:12:56 +0000 (16:12 +0200)
committerJigal van Hemert <jigal@xs4all.nl>
Thu, 28 Jun 2012 18:54:35 +0000 (20:54 +0200)
The internal cleanup feature for the table sys_history
kept the entries only for 30 days by default. This behaviour
can lead to lost information if the history is needed and
the feature wasn't known and changed.

As a replacement, the users can use the table garbage
collection scheduler task that exists for some time now.

Change-Id: Iede559e0ece282c16a54e6659c26737c8bf86d90
Resolves: #38436
Releases: 6.0
Reviewed-on: http://review.typo3.org/12404
Reviewed-by: Markus Klein
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Wouter Wolters
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
NEWS.txt
t3lib/class.t3lib_tcemain.php
typo3/class.show_rechis.inc
typo3/sysext/lang/locallang_show_rechis.xlf
typo3/sysext/scheduler/ext_localconf.php
typo3/sysext/t3editor/res/jslib/parse_typoscript/tokenizetyposcript.js

index 9df9dd9..f476b41 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -89,6 +89,12 @@ The ancient noBlur TypoScript setting for old Browsers (Internet Explorer <= 5.5
 was removed without alternative. The setting has no effect anymore and can be
 removed from custom TypoScript objects, especially MENU.
 
+* Removed internal history cleanup feature
+
+TYPO3 will not clean the history (table "sys_history") on its own anymore.
+This can lead to a large amount of data in this table. Please consider using
+the garbage collection scheduler task to remove old entries.
+
 ===============================================================================
 Changes and Improvements
 ===============================================================================
index 210bcfe..4199ea8 100644 (file)
@@ -5899,18 +5899,6 @@ class t3lib_TCEmain {
         */
        function setHistory($table, $id, $logId) {
                if (isset($this->historyRecords[$table . ':' . $id])) {
-
-                               // Initialize settings:
-                       list($tscPID) = t3lib_BEfunc::getTSCpid($table, $id, '');
-                       $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
-
-                       $tE = $this->getTableEntries($table, $TSConfig);
-                       $maxAgeSeconds = 60 * 60 * 24 * (strcmp($tE['history.']['maxAgeDays'], '') ? t3lib_utility_Math::forceIntegerInRange($tE['history.']['maxAgeDays'], 0, 365) : 30); // one month
-
-                               // Garbage collect old entries:
-                       $this->clearHistory($maxAgeSeconds, $table);
-
-                               // Set history data:
                        $fields_values = array();
                        $fields_values['history_data'] = serialize($this->historyRecords[$table . ':' . $id]);
                        $fields_values['fieldlist'] = implode(',', array_keys($this->historyRecords[$table . ':' . $id]['newRecord']));
@@ -5924,19 +5912,6 @@ class t3lib_TCEmain {
        }
 
        /**
-        * Clearing sys_history table from older entries that are expired.
-        *
-        * @param integer $maxAgeSeconds (int+) however will set a max age in seconds so that any entry older than current time minus the age removed no matter what. If zero, this is not effective.
-        * @param string $table Table where the history should be cleared
-        * @return void
-        */
-       function clearHistory($maxAgeSeconds = 604800, $table) {
-               $tstampLimit = $maxAgeSeconds ? $GLOBALS['EXEC_TIME'] - $maxAgeSeconds : 0;
-
-               $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_history', 'tstamp<' . intval($tstampLimit) . ' AND tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_history'));
-       }
-
-       /**
         * Update Reference Index (sys_refindex) for a record
         * Should be called any almost any update to a record which could affect references inside the record.
         *
index 30d6f76..55199b4 100644 (file)
@@ -364,21 +364,6 @@ class recordHistory {
                                <td>&nbsp;</td>
                        </tr>';
 
-                       // Get default page TSconfig expiration time
-               $elParts = explode(':', $this->element);
-               if ($elParts[0] != 'pages') {
-                       $tmp = t3lib_BEfunc::getRecordRaw($elParts[0], 'uid=' . intval($elParts[1]));
-                       $pid = $tmp['pid'];
-               } else {
-                       $pid = $elParts[1];
-               }
-               $tmpTsConfig = $GLOBALS['BE_USER']->getTSConfig('TCEMAIN', t3lib_BEfunc::getPagesTSconfig($pid));
-               $expirationTime = isset($tmpTsConfig['properties']['default.']['history.']['maxAgeDays']) ?
-                               $tmpTsConfig['properties']['default.']['history.']['maxAgeDays'] : 30;
-
-               $expirationTimestamp = $expirationTime ? ($GLOBALS['EXEC_TIME'] - 60 * 60 * 24 * $expirationTime) : 0;
-               $expirationWarning = 0;
-
                $be_user_array = t3lib_BEfunc::getUserNames();
 
                        // Traverse changelog array:
@@ -392,16 +377,6 @@ class recordHistory {
                                break;
                        }
 
-                               // Display inconsistency warning
-                       if ($entry['tstamp'] < $expirationTimestamp && !$expirationWarning) {
-                               $expirationWarning = 1;
-
-                               $lines[] = '
-                               <tr class="c-headLine">
-                                       <td colspan="7"><strong>' . $GLOBALS['LANG']->getLL('consistenceWarning', 1) . '</strong></td>
-                               </tr>';
-                       }
-
                                // Show only marked states
                        if (!$entry['snapshot'] && $this->showMarked) {
                                continue;
index 203b936..174964e 100644 (file)
                        <trans-unit id="showInsertDelete" xml:space="preserve">
                                <source>Show inserts/deletes of records:</source>
                        </trans-unit>
-                       <trans-unit id="consistenceWarning" xml:space="preserve">
-                               <source>From this point on, there is no guarantee that a rollback reverts all changes, as changes of records  prior to this message are normally not preserved.</source>
-                       </trans-unit>
                        <trans-unit id="noDifferences" xml:space="preserve">
                                <source>There are no differences to the current page!</source>
                        </trans-unit>
index 95a0236..890d9a7 100644 (file)
@@ -69,11 +69,19 @@ if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['t
 if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_scheduler_TableGarbageCollection']['options']['tables'])) {
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_scheduler_TableGarbageCollection']['options']['tables'] = array();
 }
-       // Register sys_log table in table garbage collection task
+       // Register sys_log and sys_history table in table garbage collection task
 if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_scheduler_TableGarbageCollection']['options']['tables']['sys_log'])) {
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_scheduler_TableGarbageCollection']['options']['tables']['sys_log'] = array(
                'dateField' => 'tstamp',
                'expirePeriod' => 180,
        );
 }
+
+if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_scheduler_TableGarbageCollection']['options']['tables']['sys_history'])) {
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_scheduler_TableGarbageCollection']['options']['tables']['sys_history'] = array(
+               'dateField' => 'tstamp',
+               'expirePeriod' => 30,
+       );
+}
+
 ?>
\ No newline at end of file
index 7032cbb..e8bd6ad 100644 (file)
@@ -559,7 +559,6 @@ var typoscriptWords = {
        'mask': 'reserved',
        'max': 'reserved',
        'maxAge': 'reserved',
-       'maxAgeDays': 'reserved',
        'maxChars': 'reserved',
        'maxH': 'reserved',
        'maxHeight': 'reserved',
@@ -1903,7 +1902,6 @@ var typoscriptWords = {
        'mask': 'reserved',
        'max': 'reserved',
        'maxAge': 'reserved',
-       'maxAgeDays': 'reserved',
        'maxChars': 'reserved',
        'maxH': 'reserved',
        'maxHeight': 'reserved',