Commit b3c932f2 authored by Helmut Hummel's avatar Helmut Hummel Committed by Felix Oertel
Browse files

[BUGFIX] Flush caches in group should throw exception

If a not existent cache group is specified
to the flushCachesInGroup methods, there is no
indication that actually nothing happened.

Throw an exception instead, so that calling code
can easily be fixed.

Resolves: #58465
Releases: 6.2
Change-Id: I9617fcee9abfa27a9cb76a3fd12543c62420e719
Reviewed-on: https://review.typo3.org/26981
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Felix Oertel
Tested-by: Felix Oertel
parent 227a7fd1
......@@ -23,6 +23,10 @@ namespace TYPO3\CMS\Core\Cache;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException;
/**
* The Cache Manager
*
......@@ -165,6 +169,7 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface {
*
* @param string $groupIdentifier
* @return void
* @throws NoSuchCacheGroupException
* @api
*/
public function flushCachesInGroup($groupIdentifier) {
......@@ -175,6 +180,8 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface {
$this->caches[$cacheIdentifier]->flush();
}
}
} else {
throw new NoSuchCacheGroupException('No cache in the specified group \'' . $groupIdentifier . '\'', 1390334120);
}
}
......@@ -185,6 +192,7 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface {
* @param string $groupIdentifier
* @param string $tag Tag to search for
* @return void
* @throws NoSuchCacheGroupException
* @api
*/
public function flushCachesInGroupByTag($groupIdentifier, $tag) {
......@@ -195,6 +203,8 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface {
$this->caches[$cacheIdentifier]->flushByTag($tag);
}
}
} else {
throw new NoSuchCacheGroupException('No cache in the specified group \'' . $groupIdentifier . '\'', 1390337129);
}
}
......
<?php
namespace TYPO3\CMS\Core\Cache\Exception;
/***************************************************************
* Copyright notice
*
* (c) 2014 TYPO3 CMS Team
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* A "No Such Cache Group" exception
*
* @api
*/
class NoSuchCacheGroupException extends \TYPO3\CMS\Core\Cache\Exception {
}
......@@ -116,6 +116,24 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
$manager->flushCaches();
}
/**
* @test
* @expectedException \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException
*/
public function flushCachesInGroupThrowsExceptionForNonExistingGroup() {
$manager = new \TYPO3\CMS\Core\Cache\CacheManager();
$manager->flushCachesInGroup('nonExistingGroup');
}
/**
* @test
* @expectedException \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException
*/
public function flushCachesInGroupByTagThrowsExceptionForNonExistingGroup() {
$manager = new \TYPO3\CMS\Core\Cache\CacheManager();
$manager->flushCachesInGroup('nonExistingGroup', 'someTag');
}
/**
* @test
*/
......
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