What happened?
Description
When viewing an entry revision and opening its tokenized preview URL, rendered template content is missing nested elements that are loaded via eagerly().
The same content loads correctly when viewing the current entry or a draft preview URL. The issue only seems to occur when previewing a revision. I also confirmed that removing the eagerly() query method resolves the issue and the nested content is rendered as expected.
The following does not work correctly in a revision preview, because childBlocks ends up empty:
{% set sections = entry.sections ?? null %}
{% for section in sections %}
<h3>SECTION</h3>
{% set childBlocks = section.blocks.eagerly().all() ?? null %}
{% for block in childBlocks %}
<h4>{{ block.type.handle|upper }} BLOCK</h4>
{% endfor %}
{% endfor %}
If I remove eagerly() and call section.blocks.all() instead, the nested elements are shown correctly in the revision preview as well.
We noticed this on an active project and were also able to reproduce it on a simple test setup.
Steps to reproduce
- Create a content model like this:
Pages (Section) → Page (Entry Type) → Sections (Matrix field, "Cards" view mode) → Section (Entry Type) → Blocks (Matrix field, "Blocks" view mode) → Block (Entry Type)
- Set up a template for the Pages section similar to the example above.
- Create a Page entry with nested elements:
Sections → Section → Blocks → Block
- Save additional revisions of the entry.
- Open a revision of the entry.
- Access the rendered template via the View action.
- Notice that nested content is missing when eagerly() is used in the template.
Expected behavior
The template should render the same content regardless of whether the preview is for the current entry, a draft, or a revision.
Actual behavior
Nested content loaded via eagerly() is missing when previewing a revision.
Craft CMS version
5.9.19
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
What happened?
Description
When viewing an entry revision and opening its tokenized preview URL, rendered template content is missing nested elements that are loaded via
eagerly().The same content loads correctly when viewing the current entry or a draft preview URL. The issue only seems to occur when previewing a revision. I also confirmed that removing the
eagerly()query method resolves the issue and the nested content is rendered as expected.The following does not work correctly in a revision preview, because childBlocks ends up empty:
If I remove
eagerly()and callsection.blocks.all()instead, the nested elements are shown correctly in the revision preview as well.We noticed this on an active project and were also able to reproduce it on a simple test setup.
Steps to reproduce
Pages (Section) → Page (Entry Type) → Sections (Matrix field, "Cards" view mode) → Section (Entry Type) → Blocks (Matrix field, "Blocks" view mode) → Block (Entry Type)Sections → Section → Blocks → Block
Expected behavior
The template should render the same content regardless of whether the preview is for the current entry, a draft, or a revision.
Actual behavior
Nested content loaded via eagerly() is missing when previewing a revision.
Craft CMS version
5.9.19
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response