[BUGFIX] TceformsUpdateWizard shows up too often
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Service / CachingFrameworkDatabaseSchemaService.php
1 <?php
2 namespace TYPO3\CMS\Install\Service;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Thomas Maroschik
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * This service provides the sql schema for the caching framework
32 */
33 class CachingFrameworkDatabaseSchemaService {
34
35 /**
36 * Get schema SQL of required cache framework tables.
37 *
38 * This method needs ext_localconf and ext_tables loaded!
39 *
40 * This is a hack, but there was no smarter solution with current cache configuration setup:
41 * ToolController sets the extbase caches to NullBackend to ensure the install tool does not
42 * cache anything. The CacheManager gets the required SQL from database backends only, so we need to
43 * temporarily 'fake' the standard db backends for extbase caches so they are respected.
44 *
45 * Additionally, the extbase_object cache is already in use and instantiated, and the CacheManager singleton
46 * does not allow overriding this definition. The only option at the moment is to 'fake' another cache with
47 * a different name, and then substitute this name in the sql content with the real one.
48 *
49 * @TODO: http://forge.typo3.org/issues/54498
50 * @TODO: It might be possible to reduce this ugly construct by circumventing the 'singleton' of CacheManager by using 'new'
51 *
52 * @return string Cache framework SQL
53 */
54 public function getCachingFrameworkRequiredDatabaseSchema() {
55 $cacheConfigurationBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
56 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array(
57 'groups' => array('system')
58 );
59 $extbaseObjectFakeName = uniqid('extbase_object');
60 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array(
61 'groups' => array('system')
62 );
63 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array(
64 'groups' => array('system')
65 );
66 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array(
67 'groups' => array('system')
68 );
69 /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
70 $cacheManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager');
71 $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
72 $cacheSqlString = \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
73 $sqlString = str_replace($extbaseObjectFakeName, 'extbase_object', $cacheSqlString);
74 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = $cacheConfigurationBackup;
75 $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
76
77 return $sqlString;
78 }
79
80 /**
81 * A slot method to inject the required caching framework database tables to the
82 * tables definitions string
83 *
84 * @param array $sqlString
85 * @return array
86 */
87 public function addCachingFrameworkRequiredDatabaseSchemaToTablesDefinition(array $sqlString) {
88 $sqlString[] = $this->getCachingFrameworkRequiredDatabaseSchema();
89 return array('sqlString' => $sqlString);
90 }
91
92 }