#109342SimpleFileBackend::require() causes exception on every cache flush
Description
*Problem*
When flushing the cache in the TYPO3 backend, an exception is thrown on
every flush request.
*Root Cause*
The ContentSecurityPolicyHeaders middleware runs in the response phase of
the same request that performs the cache flush. It calls
SiteFinder->getAllSites() which tries to load sites-configuration.php via
SimpleFileBackend::require().
The file_exists() check and the require call are not atomic:
return file_exists($pathAndFilename) ? require $pathAndFilename : false;
During a cache flush, the cache directory is removed and recreated. The
stat cache for files within the removed directory is not cleared, so
file_exists() still returns true while the file is already gone. This
causes the exception on every single cache flush.
*Steps to reproduce*
1. Click “Flush All Caches” in the backend
2. An exception is thrown
*Expected behavior*
Cache is flushed without error.
*Proposed fix*
Replace require with @include which returns false instead of triggering
a warning that TYPO3 converts to an exception:
return file_exists($pathAndFilename) ? @include($pathAndFilename) : false;
*Related*
Issue #97731
*Environment*
- TYPO3: 13.4.27
- PHP: 8.3
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Related issues 1
History 4
-
Rami El Kudr changed Related to #97731 <span data-processor="relativetime" data-value="2026-03-24T13:03:19+00:00" > 03/24/26, 13:03 </span>
-
Garvin Hicking changed subject
[BUGFIX] SimpleFileBackend::require() causes exception on every cache flushSimpleFileBackend::require() causes exception on every cache flush category <span data-processor="relativetime" data-value="2026-03-24T13:08:06+00:00" > 03/24/26, 13:08 </span> -
Oliver Hader commented and changed category <span data-processor="relativetime" data-value="2026-03-26T10:46:56+00:00" > 03/26/26, 10:46 </span>
-
Georg Ringer commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-10-23T19:15:14+00:00" > 10/23/26, 19:15 </span>Thanks for the report.
I could not reproduce this on main (15.0.0-dev). Flushing all caches in the backend via the “all caches” flush route, five times in a row, returns success every time and no exception is thrown.
Also, the described root cause does not match the code:
SimpleFileBackend::flush()removes the cache entries one by one withunlink()and does not remove and recreate the cache directory. PHP clears the stat cache for a file it unlinks itself, sofile_exists()does not report a stale “true” within the same process. A race with another process (e.g. on a shared or network file system, see #97731) is possible, but that is a different scenario and could not be confirmed here either.No further information (exception message, stack trace, cache backend and file system in use) has been provided, so there is nothing more to work with. I am closing this issue as not reproducible.
If this is still valid for you in v14, please open a new issue and provide information how to reproduce it. Thanks!
Would using
clearstatcachein the corresponding file-based caching backend solve the behavior as well?