- Issue created by @kmani
- Assigned to abhishek_virasat
- Issue was unassigned.
- 🇺🇸United States kgthompson
I am also having this issue on a D9->D10 upgraded site that heavily uses Layout Builder. I can't recreate it on a site that started as Drupal 10. Can you detail more on where your proposed changes would go?
- 🇺🇸United States bkosborne New Jersey, USA
Are you patching core/layout builder? Your error message:
Error: Call to a member function getSection() on null in Drupal\layout_builder\Form\ConfigureBlockFormBase->getCurrentSection() (line 341 of /Applications/MAMP/htdocs/xxxxxx/docroot/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php).
There is no line 341 of ConfigureBlockFormBase in Drupal 10.2.x.
- 🇮🇳India kmani
Currently, i am patching the plugin id as empty as below
diff --git a/layout_builder_styles.module b/layout_builder_styles.module
index 99d83f1..c39d150 100644
--- a/layout_builder_styles.module
+++ b/layout_builder_styles.module
@@ -19,9 +19,7 @@ function layout_builder_styles_form_alter(&$form, FormStateInterface $formState)
/** @var \Drupal\layout_builder\Form\ConfigureBlockFormBase $formObject */
$formObject = $formState->getFormObject();- $blockPluginId = $formObject
- ->getCurrentComponent()
- ->getPluginId();
+ $blockPluginId = "";$bundle = FALSE;
// If this is a reusable block, retrieve the block bundle. - 🇧🇷Brazil carolpettirossi Campinas - SP
The patch did not solve the issue for me. After I applied patch #6, I get a new error:
Error: Call to a member function getSection() on null in Drupal\layout_builder\Form\ConfigureBlockFormBase->getCurrentSection() (line 343 of /var/www/web/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php).
Backtrace:
#0 /var/www/web/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php(353): Drupal\layout_builder\Form\ConfigureBlockFormBase->getCurrentSection() #1 /var/www/web/modules/contrib/layout_builder_styles/layout_builder_styles.module(50): Drupal\layout_builder\Form\ConfigureBlockFormBase->getCurrentComponent() #2 /var/www/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(552): layout_builder_styles_form_alter(Array, Object(Drupal\Core\Form\FormState), 'layout_builder_...') #3 /var/www/web/core/lib/Drupal/Core/Form/FormBuilder.php(834): Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object(Drupal\Core\Form\FormState), 'layout_builder_...') #4 /var/www/web/core/lib/Drupal/Core/Form/FormBuilder.php(285): Drupal\Core\Form\FormBuilder->prepareForm('layout_builder_...', Array, Object(Drupal\Core\Form\FormState)) #5 /var/www/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\layout_builder\Form\AddBlockForm), Object(Drupal\Core\Form\FormState)) #6 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #7 /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #8 /var/www/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #9 /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #10 /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #11 /var/www/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #12 /var/www/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #13 /var/www/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #14 /var/www/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /var/www/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /var/www/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /var/www/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /var/www/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /var/www/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /var/www/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /var/www/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /var/www/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /var/www/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /var/www/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #25 {main}
- 🇧🇷Brazil carolpettirossi Campinas - SP
I realized I was facing this issue because of the Reusable Block patch I applied related to https://www.drupal.org/project/drupal/issues/2999491 ✨ Add reusable option to inline block creation Needs review .
Here's a patch to fix this issue when using Layout Builder Styles along with the Reusable Block patch.