[BUGFIX] Rebuild inline SVG sprite for cached pages when asset cache is lost - #44
Closed
davidsteeb wants to merge 1 commit into
Closed
[BUGFIX] Rebuild inline SVG sprite for cached pages when asset cache is lost#44davidsteeb wants to merge 1 commit into
davidsteeb wants to merge 1 commit into
Conversation
…is lost The inline SVG sprite is injected by InlineSvgInjector, which reads the collected SVG files from the "tx_assetcollector" cache. That cache lives separately from the page cache and may even sit on a different backend. When the two desync - e.g. the asset cache is cleared (or evicted) while the page cache survives - a fully cached page is delivered without the ViewHelpers being re-rendered, the collector ends up empty and the sprite is omitted: every icon on the page disappears until the page cache is regenerated. The middleware now scans the response for referenced icons (<use href="#icon-...">) and re-resolves any that are not collected from an icon registry. The registry (icon identifier => SVG file) is built from TypoScript while it is available and persisted in a dedicated cache in the "system" group, so it survives a "pages" cache flush and is available to rebuild the sprite in cached frontend scope, where TypoScript is gone. It is read lazily - only when the page actually references an uncollected icon - so regular requests are not slowed down. Also makes AssetCollector::loadTypoScript() tolerant of cached frontend scope, where FrontendTypoScript::getSetupArray() throws.
achimfritz
reviewed
Jun 16, 2026
Contributor
|
not this extension scope. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The inline SVG sprite is injected by
InlineSvgInjector, which reads the collected SVG files from thetx_assetcollectorcache. That cache is separate from the page cache and may even sit on a different backend (e.g. page cache on Redis,tx_assetcollectoron the default DB backend).When the two desync — the asset cache is cleared (or evicted) while the page cache survives — a fully cached page is delivered without the ViewHelpers being re-rendered, so the collector is empty and the sprite is omitted. Result: every icon on the page disappears until the page cache is regenerated. This shows up as “icons missing on the first load(s) after clearing the cache”.
Fix
InlineSvgInjectornow scans the response body for referenced icons (<use href="#icon-…">) and re-resolves any that are not collected from an icon registry:icon identifier => SVG file) is built from TypoScript (plugin.tx_assetcollector.icons) while it is available, and persisted in a dedicated cache in thesystemgroup — so it survives apagescache flush and is available to rebuild the sprite in cached frontend scope, where TypoScript is gone.Also makes
AssetCollector::loadTypoScript()tolerant of cached frontend scope, whereFrontendTypoScript::getSetupArray()throws ("Setup array has not been initialized…").Tests
addReferencedIcons()resolves a missing referenced icon from the registry, is a no-op (and does not even invoke the registry provider) when the icon is already collected, and ignores unknown icons.SvgViewHelperSelfHealTestreproduces the desync (page cache kept,tx_assetcollectorcache flushed) and asserts the cached page is still delivered with the full sprite.All existing unit + functional tests pass;
php-cs-fixerandphpstan(repo configs) are clean.🤖 Generated with Claude Code