[BUGFIX] Missing CSH for categories-based menus
[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 $extbaseObjectFakeName = uniqid('extbase_object');
58 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array();
59 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array();
60 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array();
61 /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
62 $cacheManager = $GLOBALS['typo3CacheManager'];
63 $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
64 $cacheSqlString = \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
65 $sqlString = str_replace($extbaseObjectFakeName, 'extbase_object', $cacheSqlString);
66 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = $cacheConfigurationBackup;
67 $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
68
69 return $sqlString;
70 }
71
72 /**
73 * A slot method to inject the required caching framework database tables to the
74 * tables defintions string
75 *
76 * @param array $sqlString
77 * @return array
78 */
79 public function addCachingFrameworkRequiredDatabaseSchemaToTablesDefintion(array $sqlString) {
80 $sqlString[] = $this->getCachingFrameworkRequiredDatabaseSchema();
81 return array('sqlString' => $sqlString);
82 }
83
84 }