[TASK] Prefix of caching framework tables is hardcoded
authorXavier Perseguers <xavier@typo3.org>
Sat, 6 Aug 2011 16:15:01 +0000 (18:15 +0200)
committerAndreas Wolf <andreas.wolf@ikt-werk.de>
Sun, 7 Aug 2011 11:31:25 +0000 (13:31 +0200)
Prefix "cachingframework_" for caching framework tables is hardcoded
at multiple places within Core.

This makes it hard to keep track of it and prevents DBAL from overriding
it when identifier length is an issue.

Change-Id: Idddcd32879b35a608b363bf8871b82407840dac2
Resolves: #28798
Reviewed-on: http://review.typo3.org/4185
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Stefan Neufeind
Reviewed-by: Andreas Wolf
Tested-by: Andreas Wolf
t3lib/cache/backend/class.t3lib_cache_backend_dbbackend.php
t3lib/class.t3lib_install_sql.php
t3lib/config_default.php
tests/t3lib/cache/backend/class.t3lib_cache_backend_dbbackendTest.php

index 4fd6b65..40a0c0d 100644 (file)
@@ -104,8 +104,9 @@ class t3lib_cache_backend_DbBackend extends t3lib_cache_backend_AbstractBackend
        public function setCache(t3lib_cache_frontend_Frontend $cache) {
                parent::setCache($cache);
 
-               $this->cacheTable = 'cachingframework_' . $this->cacheIdentifier;
-               $this->tagsTable = 'cachingframework_' . $this->cacheIdentifier . '_tags';
+               $tablePrefix = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['tablePrefix'];
+               $this->cacheTable = $tablePrefix . $this->cacheIdentifier;
+               $this->tagsTable = $tablePrefix . $this->cacheIdentifier . '_tags';
                $this->initializeCommonReferences();
        }
 
index 6c3247a..e5c1d20 100644 (file)
@@ -43,9 +43,7 @@ class t3lib_install_Sql {
        /**
         * @var array Tables starting with this name are ignored during compare
         */
-       protected $ignoreTablePrefixes = array(
-               'cachingframework_',
-       );
+       protected $ignoreTablePrefixes = array();
 
        /**
         * @var float|int Multiplier of SQL field size (for char, varchar and text fields)
@@ -64,6 +62,7 @@ class t3lib_install_Sql {
                if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['multiplyDBfieldSize'] >= 1 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['multiplyDBfieldSize'] <= 5) {
                        $this->multiplySize = (double) $GLOBALS['TYPO3_CONF_VARS']['SYS']['multiplyDBfieldSize'];
                }
+               $this->ignoreTablePrefixes[] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['tablePrefix'];
        }
 
        /**
index d7e4199..230f928 100644 (file)
@@ -125,6 +125,7 @@ $TYPO3_CONF_VARS = array(
                'reverseProxySSL' => '',                                // String: '*' or list of IP addresses of proxies that use SSL (https) for the connection to the client, but an unencrypted connection (http) to the server. If '*' all proxies defined in <a href="#SYS-reverseProxyIP">[SYS][reverseProxyIP]</a> use SSL.
                'reverseProxyPrefixSSL' => '',                          // String: prefix to be added to the internal URL (SCRIPT_NAME and REQUEST_URI) when accessing the server via an SSL proxy. This setting overrides <a href="#SYS-reverseProxyPrefix">[SYS][reverseProxyPrefix]</a>.
                'caching' => array(
+                       'tablePrefix' => 'cachingframework_',
                        'cacheConfigurations' => array(
                                'cache_hash' => array(
                                        'frontend' => 't3lib_cache_frontend_VariableFrontend',
index 1df8210..7eab1b3 100644 (file)
@@ -54,18 +54,21 @@ class t3lib_cache_backend_DbBackendTest extends tx_phpunit_testcase {
        /**
         * @var string Name of the testing data table
         */
-       protected $testingCacheTable = 'cachingframework_Testing';
+       protected $testingCacheTable;
 
        /**
         * @var string Name of the testing tags table
         */
-       protected $testingTagsTable = 'cachingframework_Testing_tags';
+       protected $testingTagsTable;
 
        /**
         * Set up testcases
         */
        public function setUp() {
                $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
+               $tablePrefix = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['tablePrefix'];
+               $this->testingCacheTable = $tablePrefix . 'Testing';
+               $this->testingTagsTable = $tablePrefix . 'Testing_tags';
        }
 
        /**
@@ -528,7 +531,7 @@ class t3lib_cache_backend_DbBackendTest extends tx_phpunit_testcase {
                $GLOBALS['TYPO3_DB'] = $this->getMock('t3lib_DB', array('exec_TRUNCATEquery', 'INSERTquery', 'sql_query', 'admin_query'));
                $GLOBALS['TYPO3_DB']->expects($this->at(2))
                        ->method('admin_query')
-                       ->with('DROP TABLE IF EXISTS cachingframework_Testing');
+                       ->with('DROP TABLE IF EXISTS ' . $this->testingCacheTable);
 
                $backend->flush();
        }
@@ -543,7 +546,7 @@ class t3lib_cache_backend_DbBackendTest extends tx_phpunit_testcase {
                $GLOBALS['TYPO3_DB'] = $this->getMock('t3lib_DB', array('exec_TRUNCATEquery', 'INSERTquery', 'sql_query', 'admin_query'));
                $GLOBALS['TYPO3_DB']->expects($this->at(3))
                        ->method('admin_query')
-                       ->with('DROP TABLE IF EXISTS cachingframework_Testing_tags');
+                       ->with('DROP TABLE IF EXISTS ' . $this->testingTagsTable);
 
                $backend->flush();
        }
@@ -570,7 +573,7 @@ class t3lib_cache_backend_DbBackendTest extends tx_phpunit_testcase {
         * @return void
         */
        public function flushCreatesDataTableCallback($sql) {
-               $startOfStatement = 'CREATE TABLE cachingframework_Testing (';
+               $startOfStatement = 'CREATE TABLE ' . $this->testingCacheTable . ' (';
                $this->assertEquals($startOfStatement, substr($sql, 0, strlen($startOfStatement)));
        }
 
@@ -596,7 +599,7 @@ class t3lib_cache_backend_DbBackendTest extends tx_phpunit_testcase {
         * @return void
         */
        public function flushCreatesTagsTableCallback($sql) {
-               $startOfStatement = 'CREATE TABLE cachingframework_Testing_tags (';
+               $startOfStatement = 'CREATE TABLE ' . $this->testingTagsTable . ' (';
                $this->assertEquals($startOfStatement, substr($sql, 0, strlen($startOfStatement)));
        }