Errors when using module with Layout Builder Restrictions

Created on 16 September 2019, over 5 years ago
Updated 9 July 2023, over 1 year ago

Problem/Motivation

Steps to reproduce:

  1. install layout_library and layout_builder_restrictions module.
  2. on page /admin/structure/layouts/add create a new layout. Entity type can be anything.
  3. create a new section.
  4. insert at least 2 blocks to the section.
  5. save the layout.
  6. now open this newly created layout to edit again.
  7. try to reorder the blocks in the section.
  8. save the layout.

Expected result:
The reordered blocks are saved in the correct order.

Actual result:
The new order is not saved. Error in log:

Error: Call to a member function getContextValue() on null in Drupal\layout_builder_restrictions\Plugin\LayoutBuilderRestriction\EntityViewModeRestriction->blockAllowedinContext() (line 109 of /var/www/html/drupal1.localhost/modules/contrib/layout_builder_restrictions/src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php) #0 /var/www/html/drupal1.localhost/modules/contrib/layout_builder_restrictions/src/Controller/MoveBlockController.php(47): Drupal\layout_builder_restrictions\Plugin\LayoutBuilderRestriction\EntityViewModeRestriction->blockAllowedinContext(Object(Drupal\layout_library\Plugin\SectionStorage\Library), '0', '0', 'content', 'b843e07f-c230-4...', NULL) #1 [internal function]: Drupal\layout_builder_restrictions\Controller\MoveBlockController->build(Object(Drupal\layout_library\Plugin\SectionStorage\Library), '0', '0', 'content', 'b843e07f-c230-4...', NULL) #2 /var/www/html/drupal1.localhost/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #3 /var/www/html/drupal1.localhost/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #4 /var/www/html/drupal1.localhost/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #5 /var/www/html/drupal1.localhost/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #6 /var/www/html/drupal1.localhost/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #7 /var/www/html/drupal1.localhost/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #8 /var/www/html/drupal1.localhost/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #9 /var/www/html/drupal1.localhost/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #10 /var/www/html/drupal1.localhost/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #11 /var/www/html/drupal1.localhost/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #12 /var/www/html/drupal1.localhost/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #13 /var/www/html/drupal1.localhost/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #14 /var/www/html/drupal1.localhost/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /var/www/html/drupal1.localhost/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /var/www/html/drupal1.localhost/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #17 {main}.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia kaszarobert

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024