Skip to content

[BUGFIX] Skip fallback if the static file vanishes while reading it - #480

Merged
lochmueller merged 1 commit into
lochmueller:mainfrom
magicHatOfTYPO3:fix/fallback-file-removed-while-reading
Nov 18, 2026
Merged

lochmueller merged 1 commit into
lochmueller:mainfrom
magicHatOfTYPO3:fix/fallback-file-removed-while-reading

Conversation

@magicHatOfTYPO3

Copy link
Copy Markdown
Contributor

Short description

FallbackMiddleware::handleViaFallback() checks that the static file exists and is readable,
and reads it afterwards. If the file is removed in between (e.g. by a cache flush from a
scheduler task or the boost queue), GeneralUtility::getUrl() returns false and
new HtmlResponse(false, ...) throws a TypeError:

TYPO3\CMS\Core\Http\HtmlResponse::__construct(): Argument #1 ($content) must be of type string,
false given, called in .../staticfilecache/Classes/Middleware/FallbackMiddleware.php on line 82

The visitor gets an error page instead of the regularly rendered page.

A failed read is now handled like a missing static file: the middleware throws its own
Exception, so process() passes the request on to TYPO3, which renders the page.

Related Issue

None. We see this in production on pages whose cache is flushed frequently (job pages that are
updated by an import every 10 minutes, together with the boost queue).

More Details

  • A unit test simulates the race: the CacheService stub removes the file in
    getAbsoluteBaseDirectory(), which is called after the file checks and before the read.
    Without the fix the test fails with the TypeError above.
  • Reproduced on a TYPO3 14.3 installation by deleting and recreating a static file in a loop
    while requesting the page: 27 of 400 requests answered with status 500 before the fix,
    none after.
  • Not a work in progress, no open issues.

🤖 Generated with Claude Code

The fallback middleware checks that the static file exists and reads
it afterwards. If the file is removed in between (e.g. by a cache
flush), GeneralUtility::getUrl() returns false and HtmlResponse throws
a TypeError. A failed read is now handled like a missing static file,
so the request is passed on to TYPO3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lochmueller
lochmueller merged commit ff003b2 into lochmueller:main Nov 18, 2026
3 checks passed
@lochmueller

Copy link
Copy Markdown
Owner

Thanks @magicHatOfTYPO3 for the fix. Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants