Problem/Motivation
There is an error after save
Mensaje de error
Close
Notice: Trying to access array offset on value of type null in Drupal\Core\Menu\Plugin\Block\LocalTasksBlock->blockSubmit() (line 153 of core/lib/Drupal/Core/Menu/Plugin/Block/LocalTasksBlock.php).
Drupal\Core\Menu\Plugin\Block\LocalTasksBlock->blockSubmit(Array, Object) (Line: 227)
Drupal\Core\Block\BlockBase->submitConfigurationForm(Array, Object) (Line: 750)
Drupal\context\Plugin\ContextReaction\Blocks->submitConfigurationForm(Array, Object) (Line: 207)
Drupal\context_ui\Form\ContextFormBase->handleReactions(Array, Object) (Line: 150)
Drupal\context_ui\Form\ContextFormBase->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 113)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('context_edit_form', Array, Object) (Line: 144)
Drupal\autosave_form\Form\AutosaveFormBuilder->processForm('context_edit_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 97)
Drupal\autosave_form\Form\AutosaveFormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 706)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
- Create a new context
- Add a block
- Save
- Edit the context
- Move the block to another region
- Click on Save and Continue
Core 9.1.10
Comments
Comment #2
paulocsI couldn't reproduce the error with the steps provided...
Can you give more details how to reproduce the error?
Comment #3
hygglo commentedI have also ran in to this issue. By removing one block at the time I've traced it down to the "Tabs" block from core.
Will post here again if I find a solution.
Comment #4
hygglo commentedok, I've made it a big further.
If you have a "Tabs" block and saving it
core/lib/Drupal/Core/Menu/Plugin/Block/LocalTasksBlock.phpIs triggered.
I'm not sure why as it doesn't make sense for it to be executed. Its then looking for
$form_state->getValue('levels');
But as that field is not in the form(it is in the Tabs form) the gives an error.
Comment #5
paulocsComment #6
mistergroove commentedI get a similar error with SystemBranding block when I save in Drupal 9.3.8 and 8.9.20... Seems related.
The line numbers slightly change between versions but the error is the same.
Seems to be the same issue as @Hygglo describes with the Tabs issue... The 'getValue' doesnt get the relevant values for the config as we are not saving the individual block configuration when the context is saved if I'm not mistaken.
Comment #7
jsidigital commentedI also get this with the tabs.
Was any solution or patch found for this?
Comment #8
Anonymous (not verified) commentedHello,
I've been trying to replicate this issue to try to resolve, but with following the steps provided in the issue summary I was unable to do so. Could you please provide more information about your issue: How did you setup the context (what conditions and reactions you're using), which theme is being used when this error occurs, are there any other modules or custom code used that interact with the blocks you've encountered this issue at?
For testing I've been using:
Drupal 9.3.8 Php 8.0
Drupal 9.5.x-dev Php 8.1
In both cases I've used the current latest development version of this module 4.x-dev (commit 86f2ca41)
Comment #9
aimevpI'm having the issue as well with following specs:
Drupal: 9.4.5
PHP: 7.4.30
Context: 8.x-4.1
It's happening on 2 custom themes. So I'm not convinced this is theme dependent.
The site was created with a custom install profile where the context was already predefined.
Condition: request-path with * as "pages" value => so all pages
Reaction: blocks
When I create a new context with only a user account menu block there is no problem.
Once I add the System Branding Block in a region for example, there errors appear.
So this has definitly something to do with form_state values core is expecting when invoking the blockSubmit() methods of those core blocks where core is expecting "block_branding", "levels", etc and context isn't providing it.
Comment #10
igork96 commentedI tried to reproduce this using Drupal: 9.4.8, PHP: 7.4.30 and Context: 8.x-4.1 but I can't... Can you please try this maybe on a fresh install of Drupal and describe the precise steps and versions to reproduce it?
Comment #11
aimevpI finally got around it to do some more testing to find out why some didn't see the issue others experienced and found the difference.
I did a clean install of Drupal 9.4.8 in combination with only context 4.1.0. These are the steps to reproduce the error:
- Install using minimal or standard profile
- Enable all messages and errors at "admin/config/development/logging"
- In case of minimal profile place the "messages" block
- Create a new context (condition: request path with value *, reaction blocks and place "site branding" for example in a region)
- Save the context
- You should see the errors.
I think the big difference was that Drupal out of the box doesn't show error messages. because in my first attempt I also couldn't reproduce it until I finally thought about the error reporting.
Comment #12
freddy rodriguezjernejmramor
This is the context config.
Comment #13
freddy rodriguezComment #14
pdxclankeith commentedI've run into this same problem on Drupal 10.1.5 and Context 5.0.0-rc1. Has there been any movement on getting a fix/patch for this?
Error message is for the SystemBrandingBlock:
Comment #15
mistergroove commentedThis issue still consistently exists for me on both 8.x-4.x and 5.0.0-rc1 on drupal 9.
Warning: Trying to access array offset on value of type null in Drupal\system\Plugin\Block\SystemBrandingBlock->blockSubmit() (line 142 of core/modules/system/src/Plugin/Block/SystemBrandingBlock.php).
Warning: Trying to access array offset on value of type null in Drupal\system\Plugin\Block\SystemBrandingBlock->blockSubmit() (line 143 of core/modules/system/src/Plugin/Block/SystemBrandingBlock.php).
Warning: Trying to access array offset on value of type null in Drupal\system\Plugin\Block\SystemBrandingBlock->blockSubmit() (line 144 of core/modules/system/src/Plugin/Block/SystemBrandingBlock.php).
To get the error add a system branding block to a context, save, update that block through context , and then click "save and continue" or "save and exit" on the context edit page.
Comment #16
cslevy commentedThis will happen for all Blocks, that has a hierarchical structure in the form.
Here the FormState is initialised with the $configuration values which is a simple array, but if you check the SystemBrandingBlock or LocalTasksBlock blockSubmits, you can see that the values from the fieldset are moved to the top level values.
So this is a general issue, and will show up for every block which has hierarchical form structure.
Comment #17
aronne commentedHi,
there's an error in the default configurations. Values were set wrong.
Attached patch.