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

Created on 22 August 2024, 4 months 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

Active

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 4 months ago
  • Assigned to pdureau
  • πŸ‡«πŸ‡·France pdureau Paris

    Cool, I will review

  • Assigned to Christian.wiedemann
  • Status changed to Needs work 4 months 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
  • Status changed to Postponed 3 months ago
  • πŸ‡«πŸ‡·France pdureau Paris
  • πŸ‡«πŸ‡·France pdureau Paris
  • πŸ‡«πŸ‡·France pdureau Paris

    Let's resume this task.

    @christian.wiederman: can you rebase your work and check if the pipelien is OK after the rebase?

    Once done, I will redo the tests with Experience Builder.

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

    According to the pipeline, there are 6 PHPCS errors to fix.

    Maybe you need to write:

        /* @phpstan-ignore method.notFound */
    

    Instead of:

        /** @phpstan-ignore method.notFound */
    

    ?

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

    Experience builder & UI Patterns 2 can be both installed in a Drupal instance. So, I am OK for merge.

    Christian, can you rebase your branch and merge to 2.0.x?

    Follow-up issue to create by pdureau:

    • When using XB components in UIP2: XB's json-schema-definitions stream wrapper is not triggered by UI Patterns 2 (normally, it must be done automatically by the JSON Schema library, without any actions on our side)
    • When using UIP2 components in XB: ValueError: "" is not a valid backing value for enum Drupal\experience_builder\JsonSchemaInterpreter\SdcPropJsonSchemaType in Drupal\experience_builder\JsonSchemaInterpreter\SdcPropJsonSchemaType::from() (line 131 of /src/PropShape/PropShape.php).
  • πŸ‡«πŸ‡·France pdureau Paris
  • πŸ‡«πŸ‡·France pdureau Paris
Production build 0.71.5 2024