Remove the LogicException in ComponentTreeLoader that forces XB to only work with article nodes

Created on 31 July 2025, 2 days ago

Overview

The first thing in \Drupal\experience_builder\Storage\ComponentTreeLoader::getXbFieldName() is a LogicException that is thrown if you try to use XB on anything except an article node.

This is not going to work for Drupal CMS. Although we do not need any ability to use XB to edit individual nodes right now -- nor do we need the ability to edit content templates in the UI -- we do need the ability to render any entity type through an existing content template (which will we hand-craft). The LogicException is a brick wall preventing that.

This blocks site templates, and therefore the full adoption of XB by Drupal CMS 2.x.

Proposed resolution

Fully remove the exception.

User interface changes

None.

πŸ“Œ Task
Status

Active

Version

1.0

Component

… to be triaged

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

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

Comments & Activities

  • Issue created by @phenaproxima
  • @phenaproxima opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Alternative approach: if we don't want to remove the exception outright, another option that will work for us is to remove this from ContentTemplateAwareViewBuilder:

          try {
            $this->componentTreeLoader->getXbFieldName($entity);
          }
          catch (\LogicException) {
            // This entity isn't opted into XB, so there's nothing else to do.
            continue;
          }
    

    This would mean we don't care if any entity is "opted into" XB or not -- only that a template exists. However, we'd certainly want to restore this logic, or equivalent logic, at a later time.

  • First commit to issue fork.
  • πŸ‡ͺπŸ‡ΈSpain isholgueras

    The only difference that this MR brings is the exception logged in the database and is step forward and we would have to delete this sooner or later. I'm OK with this.

    I've fixed one phpunit test and all should be green now.

Production build 0.71.5 2024