Component trees with dynamic prop sources that introspect field values don't add the relevant fields to their dependencies

Created on 9 April 2025, 12 days ago

Overview

If you call \Drupal\experience_builder\Plugin\Field\FieldType\ComponentTreeItem::calculateDependencies() in a tree that has dynamic prop sources that look into entity fields (bundle fields, not base fields), the field.field.foo.bar.baz config entities for those fields don't get added to the dependencies. They probably should.

Proposed resolution

TBD

User interface changes

TBD, but probably none.

🐛 Bug report
Status

Active

Version

0.0

Component

Code

Created by

🇺🇸United States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @phenaproxima
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    This is inaccurate.

    ComponentTreeItem doesn't allow DynamicPropSources. That's been the case since 📌 Tighten validation: only allow StaticPropSource in XB fields + PageTemplate, DynamicPropSource in ContentTypeTemplate Active .

    Only ContentTemplate config entities' (being introduced in #3517741, which spawned this issue to keep scope tight there) component trees will be allowed to use DynamicPropSources.

  • First commit to issue fork.
  • 🇳🇿New Zealand danielveza Brisbane, AU

    Im pretty interested in following the ContentTemplate work, so I figured I'd make a start on this one based on the IS and the discussion from #2. I've pushed up a POC of the existing work I've done so far, which now adds config dependencies for fields to the content template entities. This has test coverage, but still additional work to be done around code cleanup and removing the legacy code from `ComponentTreeItemTest`

  • Pipeline finished with Failed
    6 days ago
    Total: 1816s
    #474591
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Woohoo, thanks so much! 😊

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • 🇺🇸United States phenaproxima Massachusetts

    I did some work on this to move the dependency resolution into ComponentInputs. I also made sure that it checks for base field overrides, which are another kind of config dependency (and we do need to test for this).

  • 🇺🇸United States phenaproxima Massachusetts

    I have a question that either Wim or Lauri need to answer, brought up by this issue.

    The way the MR currently works, a content template that contains a dynamic prop expression targeting a field -- base field override or normal bundle field -- will cause the template to be dependent on that field.

    That makes sense from a data integrity standpoint, but are we not setting up a situation where, if a site builder deletes a field, all templates that mention that field are deleted too? That seems extremely bad.

    What should we do here? We probably need ContentTemplate to implement onDependencyRemoval() to handle this case in some way, or XB to be able to show a graceful fallback (assuming it doesn't already) if a prop expression is referring to a field that no longer exists. Either way, this needs product and tech lead input, so assigning this to Wim before we do any more work on it.

  • 🇫🇮Finland lauriii Finland

    We certainly should not delete the whole content template as a result of deleting a field. 😅 I think we should just remove the use of the dynamic prop from the content template. In case the deleted field happens to be a required, we replace the dynamic prop expression with example value.

  • Pipeline finished with Failed
    3 days ago
    Total: 1593s
    #476903
  • 🇺🇸United States phenaproxima Massachusetts

    Cool. This sounds like it's more of a frontend issue, then, and not really a data integrity problem (and thus, I'd imagine, not a stable blocker).

Production build 0.71.5 2024