Commit a6561904 authored by Chris Müller's avatar Chris Müller Committed by Benni Mack
Browse files

[BUGFIX] Avoid undefined array key in garbage collection task

Resolves: #96438
Releases: main, 11.5
Change-Id: Idcb8ca5f889aef8d77c1e3950f5794fe54ed76e3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72832


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent f931a62a
......@@ -44,13 +44,13 @@ class CachingFrameworkGarbageCollectionTask extends AbstractTask
public function execute()
{
// Global sub-array with all configured caches
$cacheConfigurations = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
$cacheConfigurations = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] ?? null;
if (is_array($cacheConfigurations)) {
// Iterate through configured caches and call garbage collection if
// backend is within selected backends in additional field of task
foreach ($cacheConfigurations as $cacheName => $cacheConfiguration) {
// The cache backend used for this cache
$usedCacheBackend = $cacheConfiguration['backend'];
$usedCacheBackend = $cacheConfiguration['backend'] ?? null;
if (in_array($usedCacheBackend, $this->selectedBackends)) {
GeneralUtility::makeInstance(CacheManager::class)->getCache($cacheName)->collectGarbage();
}
......
......@@ -78,6 +78,9 @@ class CachingFrameworkGarbageCollectionTest extends UnitTestCase
'frontend' => VariableFrontend::class,
'backend' => AbstractBackend::class,
],
'another_cache' => [
'frontend' => 'foo',
],
];
/** @var CachingFrameworkGarbageCollectionTask|MockObject $subject */
$subject = $this->getMockBuilder(CachingFrameworkGarbageCollectionTask::class)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment