Nested layout parsing error

On a complex site we have found a weird parsing issue with “Layout” field type. Tried to strip it down to most simple case. Test scenario:

  1. several resources (e.g. blog posts) with image Template Variable (e.g. blogImage)
  2. CB field (e.g. BlogList, type doesn’t matter) using getResources, with template reffering to image [[+tv.blogImage]]
  3. Blog list resource with single BlogList field
    This works as expected, even on very complicated layouts and templates. As expected, getResources snipped call is left unparsed by CB upon save (inspected using QuickEdit of the resource)

Now the trouble:

  1. create Layout field. Field template can be anything, for testing purposes some simple string. Doesn’t even need to contain [[+value]] reference to nested layouts
  2. PREPEND Layout field to BlogList field in Blog list resource. Doesn’t matter if any layouts inside Layout field are used.
    Upon save, getResources snippet call is parsed (snippets should be left intact). Reference to image path in parsed content is missing Media source base path, thus having wrong url.

Order of fields in Blog list resource matters! Only fields AFTER Layout field are affected. Seems like every CB field after the Layout field get it’s template parsed including snippet calls upon save, unfortunately not in a correct way.
There is a related error in log for every parsed Template variable image upon resource save:

(ERROR @ .../core/src/Revolution/modTemplateVar.php : 331) PHP warning: Undefined array key "class_key"
1 Like

Just adding a note here, for anyone wondering, that this has been resolved via modmore support.
There was a bug where using a layout field would sometimes cause incorrect parsing on resource save. Specifically, it would cause tag types such as snippets to get parsed on save rather than page load as it’s expected to do.
The fix has been identified, and will be included in the next patch release.

Thanks for finding and reporting the bug Juraj!

1 Like