Commit 38b3680e authored by Christian Kuhn's avatar Christian Kuhn Committed by Benjamin Franzke

[TASK] Simplify FileBackend->remove()

Throw if frozen, then call ->remove() of SimpleFileBackend

Resolves: #93239
Related: #92847
Releases: master
Change-Id: I01fe5d79b9adc48491ece5ed360be4e94c0e53af
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67359Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
parent f5be82d0
......@@ -218,23 +218,10 @@ class FileBackend extends SimpleFileBackend implements FreezableBackendInterface
*/
public function remove($entryIdentifier)
{
if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073035);
}
if ($entryIdentifier === '') {
throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1298114279);
}
if ($this->frozen === true) {
throw new \RuntimeException(sprintf('Cannot remove cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344193);
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if (file_exists($pathAndFilename) === false) {
return false;
}
if (@unlink($pathAndFilename) === false) {
return false;
}
return true;
return parent::remove($entryIdentifier);
}
/**
......
......@@ -598,7 +598,7 @@ class FileBackendTest extends UnitTestCase
public function removeThrowsExceptionForInvalidIdentifier(string $identifier): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1282073035);
$this->expectExceptionCode(1334756960);
$mockCache = $this->createMock(AbstractFrontend::class);
$mockCache->expects(self::atLeastOnce())->method('getIdentifier')->willReturn('UnitTestCache');
......
Markdown is supported
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