[5.x] Fix blueprint blink cache issue #12232
Merged
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.
I'm doing some heavy blueprint manipulation on a site and ran into an issue with the blueprint blink cache that would cause
EntryBlueprintFoundevents to not be dispatched after an entry has been saved for the first time.EntryBlueprintFoundevents are only dispatched once per request. Once the blueprint is in the blink cache, it will be used on subsequent requests. See the blueprint method here.This is a simple listener that I'm using in the videos below to showcase the issue:
The bug
When creating an entry, the instructions say,
Creating entry. So far, so good. But once the entry is saved, the instructions fall back to the instructions saved in the blueprint yaml rather than using the instructionsEditing entryas set in the listener.CleanShot.2025-08-29.at.17.59.42.mp4
The fix
This issue can easily be resolved by clearing the blueprint blink cache when the edit route is loaded after the entry has been saved. Honestly, I'm not quite sure if this is a great solution. It feels more like a workaround.
CleanShot.2025-08-29.at.18.00.25.mp4
Other approach
Another approach is to also dispatch the
EntryBlueprintFoundevent when the blink cache is loaded. But this kind of defeats the purpose of the blink cache.How to reproduce
I was able to reproduce this bug on a fresh installation. See this repo here.
theatrescolleciton in the CPEntry creatinginstructions on the title fieldEntry createdCleanShot.2025-09-01.at.09.42.44.mp4
What causes the bug
I tracked the issue down to a query in the
AppServiceProviderof my site. If you remove the query, the blueprint fields are ensured as expected.A potential solution for this scenario
The bug can also be fixed by clearing the Blink cache directly in the service provider. But I'm not sure this is a good solution either.
A similar bug
I noticed a similar blueprint caching bug when a blueprint contains a
parentfield. This is the case with structured collections or if the blueprint contains aparententries fieldtype.Check out the
Pagescollection. The title instructions will always readEntry creating. Even when editing an existing entry. This is likely the underlying issue as in the theatres collection, as the pages collection is queried by theparententries fieldtype.However, the fix provided in this PR doesn't solve the issue in this scenario.
CleanShot.2025-09-01.at.09.42.04.mp4