Skip to content

fix: Clear Fusion caches when translation overrides are updated#23

Merged
mficzel merged 3 commits intositegeist:mainfrom
paavo:master
Jan 29, 2026
Merged

fix: Clear Fusion caches when translation overrides are updated#23
mficzel merged 3 commits intositegeist:mainfrom
paavo:master

Conversation

@paavo
Copy link
Contributor

@paavo paavo commented Jan 14, 2026

When updating translation overrides via the Neos backend module, the package was only clearing its own translation cache but not the Fusion caches where translated content is rendered.

This caused stale translations to persist in the frontend until caches were manually flushed, particularly affecting components like CookieConsent that use CsvPO translations in Fusion prototypes.

Changes

Core Implementation

  • Inject CacheManager into TranslationLabelSource
  • Modified flushCaches() to conditionally flush Neos_Fusion_Content cache
  • Only flushes Neos_Fusion_Content (rendered output), not Neos_Neos_Fusion (parsed Fusion AST)
  • Added inline documentation explaining cache flushing logic

Configuration

  • Added new setting: management.flushNeosFusionContentCacheOnTranslationUpdate
  • Defaults to false to prevent performance issues on high-traffic sites
  • Users can enable it when they need instant translation updates

Documentation

  • Documented the new setting in README.md Configuration section
  • Added note in Caching section explaining when and why to use this feature

How it Works

The fix ensures that when translations are updated through:

  • TranslationController::addOverrideAction()
  • TranslationController::saveOverrideAction()
  • TranslationController::deleteOverrideAction()

The rendered Fusion content using those translations is regenerated on the next request (if enabled), making translation changes immediately visible in the frontend.

Addresses Review Feedback

This PR has been updated based on @mficzel's review:

  • ✅ Removed unnecessary Neos_Neos_Fusion cache flush (stores parsed Fusion AST, not content)
  • ✅ Made cache flushing configurable to avoid performance impact
  • ✅ Defaults to disabled for safety

@mficzel

When updating translation overrides via the Neos backend module, the
package was only clearing its own translation cache but not the Fusion
caches where translated content is rendered.

This caused stale translations to persist in the frontend until caches
were manually flushed, particularly affecting components like
CookieConsent that use CsvPO translations in Fusion prototypes.

Changes:
- Inject CacheManager into TranslationLabelSource
- Modified flushCaches() to also flush Neos_Neos_Fusion cache
- Modified flushCaches() to also flush Neos_Fusion_Content cache
- Added inline documentation explaining why Fusion caches need clearing

The fix ensures that when translations are updated through:
- TranslationController::addOverrideAction()
- TranslationController::saveOverrideAction()
- TranslationController::deleteOverrideAction()

The rendered Fusion content using those translations is regenerated
on the next request, making translation changes immediately visible
in the frontend.

Fixes cache invalidation for Fusion prototypes using CsvPO translations
Copy link
Member

@mficzel mficzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree to flushing Neos_Fusion_Content but wonder why the Neos_Neos_Fusion is flushed aswell. I may be wrong but as far as i am aware this stores the fusion not the evaluated result so it only has to be flushed when fusion files change.

Also Triggering a full fusion cache flush with every edit is quite a hard gun. I would prefer to have a configuration for that to disable it quickly if it causes trouble.

…d targeted

Addresses review feedback from mficzel on PR sitegeist#23:

1. Remove Neos_Neos_Fusion cache flush:
   - This cache stores parsed Fusion AST, not rendered content
   - Only needs flushing when Fusion files change, not when translations change

2. Keep only Neos_Fusion_Content cache flush:
   - This cache stores rendered/evaluated content that includes translations
   - Needs flushing when translations change to regenerate content

3. Make cache flush configurable:
   - Add new setting: management.flushNeosFusionContentCacheOnTranslationUpdate
   - Defaults to false to prevent performance issues
   - Allows disabling if cache flush causes trouble in production

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@paavo paavo requested a review from mficzel January 16, 2026 12:16
Address PHP CodeSniffer violations:
- Move first expression after opening parenthesis to new line
- Place closing parenthesis on separate line before opening brace

This follows PSR12 standards for multi-line control structures.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@paavo
Copy link
Contributor Author

paavo commented Jan 29, 2026

@mficzel i fixed the code-style, so the checks passed 🎉
ready for merging?

@mficzel mficzel merged commit 554cd79 into sitegeist:main Jan 29, 2026
2 checks passed
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