[later phase] Implement Component::onDependencyRemoval

Created on 30 August 2024, 4 months ago

Overview

I was testing the demo design system. Because we can't scroll the components panel until šŸ› Unable to scroll component list Fixed , I went ahead and deleted all of the built-in components to make the demo design system components visible. After this, I'm getting a PHP error when I'm trying to access Experience Builder:

InvalidArgumentException: Field field_xb_demo is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 616 of /var/www/html/drupal/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

#0 /var/www/html/drupal/core/lib/Drupal/Core/Entity/ContentEntityBase.php(597): Drupal\Core\Entity\ContentEntityBase->getTranslatedField()
#1 /var/www/html/drupal/modules/custom/experience_builder/src/Controller/SdcController.php(277): Drupal\Core\Entity\ContentEntityBase->get()
#2 [internal function]: Drupal\experience_builder\Controller\SdcController->layout()
#3 /var/www/html/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#4 /var/www/html/drupal/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#5 /var/www/html/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#6 /var/www/html/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#7 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#8 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#9 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#10 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#11 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#12 /var/www/html/drupal/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#13 /var/www/html/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#14 /var/www/html/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#15 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#16 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#17 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#18 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#19 /var/www/html/drupal/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#20 /var/www/html/drupal/index.php(19): Drupal\Core\DrupalKernel->handle()
#21 {main}

Proposed resolution

User interface changes

šŸ“Œ Task
Status

Postponed

Component

Config management

Created by

šŸ‡«šŸ‡®Finland lauriii Finland

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

  • Issue created by @lauriii
  • Status changed to Fixed 4 months ago
  • šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ
    Field field_xb_demo is unknown.
    

    šŸ‘†

    This is a clear tell that you've deleted a FieldConfig entity šŸ˜œ

    You probably deleted one of the three config dependencies for that field instance:

    ā€¦
    dependencies:
      config:
        - experience_builder.component.experience_builder+image
        - experience_builder.component.experience_builder+my-hero
        - experience_builder.component.experience_builder+two_column
    ā€¦
    

    Deleting the hero one for example triggers:

  • šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    Conceptually related issues linked.

  • šŸ‡«šŸ‡®Finland lauriii Finland

    Woah šŸ¤Æ I didn't notice this when I was deleting the components. This seems like a fairly severe problem because I assume it deleted all of the XB content as a result?

  • šŸ‡«šŸ‡®Finland lauriii Finland

    Didn't intend to remove the related issue.

  • Status changed to Postponed 4 months ago
  • šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    #4: that's how config dependencies work.

    You must first update that config, then delete it. You were informed of the consequences. That's not severe, that's intentional.

    We could implement \Drupal\Core\Config\Entity\ConfigEntityBase::onDependencyRemoval() to remove that component from the tree. But that too won't always work: if the component being removed contains components in its slots, then we wouldn't know how to remove it sanely. ā‡’ It's better to ask the Site Builder to update the config first.

    Even more so once the slot restrictions mentioned in šŸ“Œ [SPIKE] Comprehensive plan for integrating with SDC Active are a reality: then it becomes very likely that contained components cannot simply be moved "up a level".

    Only simple scenarios could be covered by \Drupal\Core\Config\Entity\ConfigEntityInterface::onDependencyRemoval() ā€” i.e. for deleting leafs of the (default) component tree.

    Repurposing this issue to handle those simple scenarios.

Production build 0.71.5 2024