caching_framework.patch

Benni Mack, 2014-01-15 09:31

Download (18.8 KB)

View differences:

typo3/sysext/core/Classes/Cache/CacheManager.php
50 50
	protected $cacheConfigurations = array();
51 51

  
52 52
	/**
53
	 * used to flush caches of a specific group
54
	 * is an associative array containing the group identifier as key
55
	 * and the identifier as an array within that group
56
	 * groups are set via the cache configurations of each cache
57
	 * @var array
58
	 */
59
	protected $cacheGroups = array();
60

  
61
	/**
53 62
	 * @var array Default cache configuration as fallback
54 63
	 */
55 64
	protected $defaultCacheConfiguration = array(
56 65
		'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend',
57 66
		'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend',
58
		'options' => array()
67
		'options' => array(),
68
		'groups' => array('unassigned')
59 69
	);
60 70

  
61 71
	/**
......
150 160
	}
151 161

  
152 162
	/**
163
	 * Flushes all registered caches of a specific group
164
	 *
165
	 * @param string $groupIdentifier
166
	 * @return void
167
	 * @api
168
	 */
169
	public function flushCachesInGroup($groupIdentifier) {
170
		$this->createAllCaches();
171
		if (isset($this->cacheGroups[$groupIdentifier])) {
172
			foreach ($this->cacheGroups[$groupIdentifier] as $cacheIdentifier) {
173
				if (isset($this->caches[$cacheIdentifier])) {
174
					$this->caches[$cacheIdentifier]->flush();
175
				}
176
			}
177
		}
178
	}
179

  
180
	/**
181
	 * Flushes entries tagged by the specified tag of all registered
182
	 * caches of a specific group.
183
	 *
184
	 * @param string $groupIdentifier
185
	 * @param string $tag Tag to search for
186
	 * @return void
187
	 * @api
188
	 */
189
	public function flushCachesInGroupByTag($groupIdentifier, $tag) {
190
		$this->createAllCaches();
191
		if (isset($this->cacheGroups[$groupIdentifier])) {
192
			foreach ($this->cacheGroups[$groupIdentifier] as $cacheIdentifier) {
193
				if (isset($this->caches[$cacheIdentifier])) {
194
					$this->caches[$cacheIdentifier]->flushByTag($tag);
195
				}
196
			}
197
		}
198
	}
199

  
200

  
201
	/**
153 202
	 * Flushes entries tagged by the specified tag of all registered
154 203
	 * caches.
155 204
	 *
......
299 348
	 *
300 349
	 * @param string $identifier
301 350
	 * @return void
351
	 * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidCacheException when the groups parameter is not set
302 352
	 */
303 353
	protected function createCache($identifier) {
304 354
		if (isset($this->cacheConfigurations[$identifier]['frontend'])) {
......
316 366
		} else {
317 367
			$backendOptions = $this->defaultCacheConfiguration['options'];
318 368
		}
369

  
370
		// add the cache to the groups that it should be attached, or use the default ones
371
		if (isset($this->cacheConfigurations[$identifier]['groups']) && is_array($this->cacheConfigurations[$identifier]['groups'])) {
372
			$assignedGroups = $this->cacheConfigurations[$identifier]['groups'];
373
		} else {
374
			$assignedGroups = $this->defaultCacheConfiguration['groups'];
375
		}
376
		foreach ($assignedGroups as $groupIdentifier) {
377
			if (!is_array($this->cacheGroups[$groupIdentifier])) {
378
				$this->cacheGroups[$groupIdentifier] = array();
379
			}
380
			$this->cacheGroups[$groupIdentifier][] = $identifier;
381
		}
382

  
319 383
		$this->cacheFactory->create($identifier, $frontend, $backend, $backendOptions);
320 384
	}
321 385

  
typo3/sysext/core/Classes/DataHandling/DataHandler.php
6931 6931
	/**
6932 6932
	 * Clears the cache based on the command $cacheCmd.
6933 6933
	 *
6934
	 * $cacheCmd='pages':	Clears cache for all pages. Requires admin-flag to
6935
	 * be set for BE_USER.
6934
	 * $cacheCmd='pages'
6935
	 * Clears cache for all pages and page-based caches inside the cache manager.
6936
	 * Requires admin-flag to be set for BE_USER.
6936 6937
	 *
6937
	 * $cacheCmd='all':		Clears all cache_tables. This is necessary if
6938
	 * templates are updated. Requires admin-flag to be set for BE_USER.
6938
	 * $cacheCmd='all'
6939
	 * Clears all cache_tables. This is necessary if templates are updated.
6940
	 * Requires admin-flag to be set for BE_USER.
6939 6941
	 *
6940
	 * $cacheCmd=[integer]:	Clears cache for the page pointed to by $cacheCmd
6941
	 * (an integer).
6942
	 * The following cache_* are intentionally not cleared by 'all'
6942 6943
	 *
6943
	 * $cacheCmd='cacheTag:[string]':  Flush page and pagesection cache by given tag
6944
	 * - cache_md5params:	RDCT redirects.
6945
	 * - cache_imagesizes:	Clearing this table would cause a lot of unneeded
6946
	 * Imagemagick calls because the size informations have
6947
	 * to be fetched again after clearing.
6948
	 * - all caches inside the cache manager that are inside the group "system"
6949
	 * - they are only needed to build up the core system and templates,
6950
	 *   use "temp_cached" or "system" to do that
6951
	 *
6952
	 * $cacheCmd=[integer]
6953
	 * Clears cache for the page pointed to by $cacheCmd (an integer).
6944 6954
	 *
6945
	 * $cacheCmd='cacheId:[string]':  Removes cache identifier from page and page section cache
6955
	 * $cacheCmd='cacheTag:[string]'
6956
	 * Flush page and pagesection cache by given tag
6957
	 *
6958
	 * $cacheCmd='cacheId:[string]'
6959
	 * Removes cache identifier from page and page section cache
6946 6960
	 *
6947 6961
	 * Can call a list of post processing functions as defined in
6948 6962
	 * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']
6949 6963
	 * (numeric array with values being the function references, called by
6950 6964
	 * GeneralUtility::callUserFunction()).
6951 6965
	 *
6952
	 * Note: The following cache_* are intentionally not cleared by
6953
	 * $cacheCmd='all':
6954
	 *
6955
	 * - cache_md5params:	RDCT redirects.
6956
	 * - cache_imagesizes:	Clearing this table would cause a lot of unneeded
6957
	 * Imagemagick calls because the size informations have
6958
	 * to be fetched again after clearing.
6959 6966
	 *
6960 6967
	 * @param string $cacheCmd The cache command, see above description
6961 6968
	 * @return void
6969
	 * @throws \RuntimeException
6962 6970
	 */
6963 6971
	public function clear_cacheCmd($cacheCmd) {
6964 6972
		if (is_object($this->BE_USER)) {
......
6968 6976
		switch (strtolower($cacheCmd)) {
6969 6977
			case 'pages':
6970 6978
				if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.pages')) {
6971
					$this->internal_clearPageCache();
6979
					$GLOBALS['typo3CacheManager']->flushCachesInGroup('pages');
6972 6980
				}
6973 6981
				break;
6974 6982
			case 'all':
6975 6983
				if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
6976 6984
					// Clear all caching framework caches
6977
					$GLOBALS['typo3CacheManager']->flushCaches();
6985
					$GLOBALS['typo3CacheManager']->flushCachesInGroup('pages');
6986
					$GLOBALS['typo3CacheManager']->flushCachesInGroup('unassigned');
6978 6987
					if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
6979 6988
						$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cache_treelist');
6980 6989
					}
......
6989 6998
						}
6990 6999
					}
6991 7000
				}
6992
				\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
7001

  
6993 7002
				break;
6994 7003
			case 'temp_cached':
6995
				\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
7004
			case 'system':
7005
				if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.system') || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
7006
					$GLOBALS['typo3CacheManager']->flushCachesInGroup('system');
7007
				}
6996 7008
				break;
6997 7009
		}
7010

  
6998 7011
		$tagsToFlush = array();
6999 7012
		// Clear cache for a page ID!
7000 7013
		if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($cacheCmd)) {
......
7023 7036
		}
7024 7037
		// process caching framwork operations
7025 7038
		if (count($tagsToFlush) > 0) {
7026
			/** @var $pageCache \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend */
7027
			$pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
7028
			/** @var $pageSectionCache \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend */
7029
			$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
7030
			/** @var $hashCache \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend */
7031
			$hashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
7032 7039
			foreach ($tagsToFlush as $tag) {
7033
				$pageCache->flushByTag($tag);
7034
				$pageSectionCache->flushByTag($tag);
7035
				$hashCache->flushByTag($tag);
7040
				$GLOBALS['typo3CacheManager']->flushCachesInGroupByTag('pages', $tag);
7036 7041
			}
7037 7042
		}
7043

  
7038 7044
		// Call post processing function for clear-cache:
7039 7045
		if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'])) {
7040 7046
			$_params = array('cacheCmd' => strtolower($cacheCmd));
......
7148 7154
	 *
7149 7155
	 * @return void
7150 7156
	 * @todo Define visibility
7157
	 * @deprecated since TYPO3 CMS 6.2, remove two versions later
7151 7158
	 */
7152 7159
	public function internal_clearPageCache() {
7153
		if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
7154
			$GLOBALS['typo3CacheManager']->getCache('cache_pages')->flush();
7155
		}
7160
		GeneralUtility::logDeprecatedFunction('The DataHandler clearPageCache method is deprecated, use the cache manager directly.');
7161
		$GLOBALS['typo3CacheManager']->flushGroups('pages');
7156 7162
	}
7157 7163

  
7158 7164
	/**
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
1744 1744
	}
1745 1745

  
1746 1746
	/**
1747
	 * Remove cache files from php code cache, tagged with 'core'
1747
	 * Remove cache files from php code cache, grouped by 'system'
1748 1748
	 *
1749 1749
	 * This removes the following cache entries:
1750 1750
	 * - autoloader cache registry
......
1759 1759
	 * @return void
1760 1760
	 */
1761 1761
	static public function removeCacheFiles() {
1762
		/** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
1763
		$codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
1764
		$codeCache->flush();
1762
		$GLOBALS['typo3CacheManager']->flushCachesInGroup('system');
1765 1763
	}
1766 1764

  
1767 1765
	/**
typo3/sysext/core/Configuration/DefaultConfiguration.php
132 132
				'cache_core' => array(
133 133
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\PhpFrontend',
134 134
					'backend' => 'TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend',
135
					'options' => array()
135
					'options' => array(
136
						'defaultLifetime' => 0,
137
					),
138
					'groups' => array('system')
136 139
				),
137 140
				'cache_classes' => array(
138 141
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\StringFrontend',
139 142
					'backend' => 'TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend',
140
					'options' => array()
143
					'options' => array(
144
						'defaultLifetime' => 0,
145
					),
146
					'groups' => array('system')
141 147
				),
142 148
				'cache_hash' => array(
143 149
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
144 150
					'backend' => 'TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend',
145
					'options' => array()
151
					'options' => array(),
152
					'groups' => array('pages')
146 153
				),
147 154
				'cache_pages' => array(
148 155
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
149 156
					'backend' => 'TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend',
150 157
					'options' => array(
151 158
						'compression' => TRUE
152
					)
159
					),
160
					'groups' => array('pages')
153 161
				),
154 162
				'cache_pagesection' => array(
155 163
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
156 164
					'backend' => 'TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend',
157 165
					'options' => array(
158 166
						'compression' => TRUE
159
					)
167
					),
168
					'groups' => array('pages')
160 169
				),
161 170
				'cache_phpcode' => array(
162 171
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\PhpFrontend',
163 172
					'backend' => 'TYPO3\CMS\Core\Cache\Backend\FileBackend',
164
					'options' => array()
173
					'options' => array(
174
						'defaultLifetime' => 0,
175
					),
176
					'groups' => array('system')
165 177
				),
166 178
				'cache_runtime' => array(
167 179
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
168 180
					'backend' => 'TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend',
169
					'options' => array()
181
					'options' => array(),
182
					'groups' => array()
170 183
				),
171 184
				'cache_rootline' => array(
172 185
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
173 186
					'backend' => 'TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend',
174
					'options' => array()
187
					'options' => array(),
188
					'groups' => array('pages')
175 189
				),
176 190
				't3lib_l10n' => array(
177 191
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
178 192
					'backend' => 'TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend',
179
					'options' => array(),
193
					'options' => array(
194
						'defaultLifetime' => 0,
195
					),
196
					'groups' => array('system')
180 197
				),
181 198
				'extbase_object' => array(
182 199
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
......
184 201
					'options' => array(
185 202
						'defaultLifetime' => 0,
186 203
					),
204
					'groups' => array('system')
187 205
				),
188 206
				'extbase_reflection' => array(
189 207
					'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
......
191 209
					'options' => array(
192 210
						'defaultLifetime' => 0,
193 211
					),
212
					'groups' => array('system')
194 213
				),
195 214
			),
196 215
		),
typo3/sysext/dbal/ext_localconf.php
10 10
// Register caches if not already done in localconf.php or a previously loaded extension.
11 11
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['dbal'])) {
12 12
	$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['dbal'] = array(
13
		'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\TransientMemoryBackend'
13
		'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\TransientMemoryBackend',
14
		'groups' => array()
14 15
	);
15 16
}
typo3/sysext/extbase/ext_localconf.php
7 7
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('extbase') . 'Classes/Utility/ExtensionUtility.php';
8 8

  
9 9
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'])) {
10
	$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array();
10
	$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array(
11
		'groups' => array('system')
12
	);
11 13
}
12 14
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'])) {
13
	$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array();
15
	$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array(
16
		'groups' => array('system')
17
	);
14 18
}
15 19

  
16 20
// We need to set the default implementation for Storage Backend & Query Settings
typo3/sysext/fluid/ext_localconf.php
6 6
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['fluid_template'])) {
7 7
	$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['fluid_template'] = array(
8 8
		'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend',
9
		'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend'
9
		'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend',
10
		'groups' => array('system')
10 11
	);
11 12
}
typo3/sysext/install/Classes/Service/SqlExpectedSchemaService.php
112 112
	 */
113 113
	public function getCachingFrameworkRequiredDatabaseSchema() {
114 114
		$cacheConfigurationBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
115
		$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array();
115
		$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array(
116
			'groups' => array('system')
117
		);
116 118
		$extbaseObjectFakeName = uniqid('extbase_object');
117
		$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array();
118
		$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array();
119
		$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array();
119
		$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array(
120
			'groups' => array('system')
121
		);
122
		$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array(
123
			'groups' => array('system')
124
		);
125
		$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array(
126
			'groups' => array('system')
127
		);
120 128
		/** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
121 129
		$cacheManager = $GLOBALS['typo3CacheManager'];
122 130
		$cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
typo3/sysext/workspaces/ext_localconf.php
29 29

  
30 30
// Register workspaces cache if not already done in localconf.php or a previously loaded extension.
31 31
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['workspaces_cache'])) {
32
	$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['workspaces_cache'] = array();
32
	$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['workspaces_cache'] = array(
33
		'groups' => array('pages')
34
	);
33 35
}
34 36

  
35 37
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('options.workspaces.considerReferences = 1');