[2.0.0-beta3] plugin.manager.sdc conflict with Experience Builder

Created on 22 August 2024, 25 days ago
Updated 5 September 2024, 11 days ago

Problem/Motivation

If both Experience Builder and UI Patterns 2.x are activated in the same time, the site break (all pages are WSOD):

TypeError: Drupal\ui_patterns_layouts\Plugin\Derivative\ComponentLayout::__construct(): Argument #1 ($pluginManager) must be of type
Drupal\ui_patterns\ComponentPluginManager,

It may be our fault :)

Experience Builder is decorating plugin.manager.sdc:

Drupal\experience_builder\Plugin\ComponentPluginManager:
    decorates: plugin.manager.sdc
    parent: plugin.manager.sdc
    calls:
      - [setEntityTypeManager, ['@entity_type.manager']]

We are overriding the service:

  plugin.manager.sdc:
    class: Drupal\ui_patterns\ComponentPluginManager
    arguments:
      - "@module_handler"
      - "@theme_handler"
      - "@cache.discovery"
      - "@config.factory"
      - "@theme.manager"
      - '@Drupal\Core\Theme\ComponentNegotiator'
      - "@file_system"
      - '@Drupal\Core\Theme\Component\SchemaCompatibilityChecker'
      - '@Drupal\Core\Theme\Component\ComponentValidator'
      - "%app.root%"
      - "@plugin.manager.ui_patterns_prop_type"
      - "@plugin.manager.ui_patterns_prop_type_adapter"
      - "@ui_patterns.schema_reference_solver"
      - "@extension.list.module"

https://git.drupalcode.org/project/experience_builder/-/blob/0.x/experie...

Proposed resolution

Is switching to a decorator the solution of our problem? It seems we already tried this spring, no? What was the issue?

πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France pdureau Paris

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

Merge Requests

Comments & Activities

  • Issue created by @pdureau
  • Assigned to Christian.wiedemann
  • πŸ‡«πŸ‡·France pdureau Paris
  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    christian.wiedemann β†’ made their first commit to this issue’s fork.

  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    I decorated plugin.manager.sdc instead of overwriting and I updated the layout builder deriver to use the original service.

  • Status changed to Needs review 19 days ago
  • Assigned to pdureau
  • πŸ‡«πŸ‡·France pdureau Paris

    Cool, I will review

  • Assigned to Christian.wiedemann
  • Status changed to Needs work 18 days ago
  • πŸ‡«πŸ‡·France pdureau Paris

    Pipeline issues

    phpstan:

    Line modules/ui_patterns_devel/tests/src/Kernel/TwigValidatorTestBase.php
    39 Property
    Drupal\Tests\ui_patterns_devel\Kernel\TwigValidatorTestBase::$componentPluginManager
    (Drupal\ui_patterns\ComponentPluginManager) does not accept
    Drupal\Core\Theme\ComponentPluginManager.
    ------ --------------------------------------------------------------------------------------
    Line modules/ui_patterns_devel/tests/src/Kernel/ValidatorTest.php
    46 Property
    Drupal\Tests\ui_patterns_devel\Kernel\ValidatorTest::$componentPluginManager
    (Drupal\ui_patterns\ComponentPluginManager) does not accept
    Drupal\Core\Theme\ComponentPluginManager.
    ------ ------------------------------------------------------------------------------
    Line modules/ui_patterns_field_formatters/src/Plugin/Field/FieldFormatter/ComponentFormatterBase.php
    65 Property
    Drupal\ui_patterns_field_formatters\Plugin\Field\FieldFormatter\ComponentFormatterBase::$componentPluginManager
    (Drupal\ui_patterns\ComponentPluginManager) does not accept
    Drupal\Core\Theme\ComponentPluginManager.
    ------ -----------------------------------------------------------------------
    Line modules/ui_patterns_layouts/src/Plugin/Derivative/ComponentLayout.php
    41 Call to an undefined method
    Drupal\Core\Theme\ComponentPluginManager::getSortedDefinitions().
    ------ ---------------------------------------
    Line src/ComponentPluginManager.php
    14 Plugin definitions cannot be altered.
    ------ ---------------------------------------
    Line src/Element/ComponentForm.php
    172 Call to an undefined method
    Drupal\Core\Theme\ComponentPluginManager::getGroupedDefinitions().
    ------ ----------------------------------------------------------------------
    Line tests/src/Kernel/ComponentPluginManagerTest.php
    43 Property
    Drupal\Tests\ui_patterns\Kernel\ComponentPluginManagerTest::$manager
    (Drupal\ui_patterns\ComponentPluginManager) does not accept
    Drupal\Core\Theme\ComponentPluginManager.

    Maybe more.

    Tests without experience builder

    After switching to the branch, I got:

    Uncaught PHP Exception Error: "Typed property Drupal\ui_patterns\ComponentPluginManager::$propTypePluginManager must not be accessed before initialization" at /home/pierre/Projects/Drupal/ui_patterns_2/web/modules/custom/ui_patterns/src/ComponentPluginManager.php line 59

    A fresh install fixed this. Do we really need to do such a fresh install?

    Everything seems fine: summary is created, props are typed...

    Test 1 with Experience Builder

    commit 938ca03cce282bdc79da802efd0d3850751994d3 (HEAD -> 0.x, origin/HEAD, origin/0.x)
    Date: Thu Aug 22 18:34:17 2024 +0000

    UI Patterns 2 with experience builder components

    /patterns/experience_builder shows the Experience Builder's SDC component βœ…

    Except the resolution of "$ref":"json-schema-definitions:// but tit seems the stream wrapper is not ready at the XB side

    Component "Shoe button" can be used with ComponentBlock βœ…

    Experience builder with the UI Patterns 2 component

    This warning: PHP Warning: Undefined array key "props" in experience_builder/src/Plugin/ComponentPluginManager.php on line 58

    And a fatal error on /xb/node/1: An unexpected error has occurred while fetching layouts. SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

    So, not possible to test more.

    Test 2 with Experience Builder

    After a git pull, npm i & nom run build:

    commit 7cb3623d22582ba7eae4dfb551a402c7d5a1c45c (HEAD -> 0.x, origin/HEAD, origin/0.x)
    Date: Wed Aug 28 15:26:32 2024 +0000

    I have this fatal: Drupal\experience_builder\PropShape::resolveSchemaReferences(): Argument #1 ($schema) must be of type array, string given

    A fresh Drupal reinstall is not fixing it. So, not possible to test more.

  • πŸ‡«πŸ‡·France pdureau Paris

    Moved to beta3 because:

    • There is many active and breaking changes currently nExperience builder
    • We may need to push a fix in Core before anyway
Production build 0.71.5 2024