Config schema is wrong and changing the available blocks for a "Block (plugin)" field produces a Recoverable fatal error

Created on 17 March 2017, over 7 years ago
Updated 8 November 2023, about 1 year ago

Hi!
I spun up a site with this module and the devel module. I enable them both plus devel_generate.

I added an entity reference field to the Article content type called "Related Pages" referencing the "Basic Page" content type.

I created a view that I could place on the "Basic Page"content type that would list the related articles.

I created a new field on the "Basic Page" content type of the field type "Block (plugin)". The view I created was not one of the available blocks. I selected it and clicked save. This is when I got the error. I have since then figured out that any change to the available blocks (ticking or unticking the boxes next to the blocks) causes this error. In the browser the error is:

The website encountered an unexpected error. Please try again later.

In the system log the error message is much more verbose and follows.

Thanks for investigating this error as it makes the module unusable if I cannot change the available blocks!

Frederick

Location https://dgz75.ply.st/admin/structure/types/manage/page/fields/node.page....
Referrer https://dgz75.ply.st/admin/structure/types/manage/page/fields/node.page....
Message Recoverable fatal error: Argument 1 passed to Drupal\Core\Form\SubformState::createForSubform() must be of the type array, null given, called in /home/dgz75/www/sites/default/modules/block_field/src/Plugin/Field/FieldWidget/BlockFieldWidget.php on line 208 and defined in Drupal\Core\Form\SubformState::createForSubform() (line 56 of /home/dgz75/www/core/lib/Drupal/Core/Form/SubformState.php) #0 /home/dgz75/www/core/includes/bootstrap.inc(548): _drupal_error_handler_real(4096, 'Argument 1 pass...', '/home/dgz75/www...', 56, Array) #1 /home/dgz75/www/core/lib/Drupal/Core/Form/SubformState.php(56): _drupal_error_handler(4096, 'Argument 1 pass...', '/home/dgz75/www...', 56, Array) #2 /home/dgz75/www/sites/default/modules/block_field/src/Plugin/Field/FieldWidget/BlockFieldWidget.php(208): Drupal\Core\Form\SubformState::createForSubform(NULL, Array, Object(Drupal\Core\Form\FormState)) #3 /home/dgz75/www/core/lib/Drupal/Core/Field/WidgetBase.php(370): Drupal\block_field\Plugin\Field\FieldWidget\BlockFieldWidget->massageFormValues(Array, Array, Object(Drupal\Core\Form\FormState)) #4 /home/dgz75/www/core/lib/Drupal/Core/Field/FieldItemList.php(314): Drupal\Core\Field\WidgetBase->extractFormValues(Object(Drupal\Core\Field\FieldItemList), Array, Object(Drupal\Core\Form\FormState)) #5 /home/dgz75/www/core/modules/field_ui/src/Form/FieldConfigEditForm.php(153): Drupal\Core\Field\FieldItemList->defaultValuesFormValidate(Array, Array, Object(Drupal\Core\Form\FormState)) #6 [internal function]: Drupal\field_ui\Form\FieldConfigEditForm->validateForm(Array, Object(Drupal\Core\Form\FormState)) #7 /home/dgz75/www/core/lib/Drupal/Core/Form/FormValidator.php(83): call_user_func_array(Array, Array) #8 /home/dgz75/www/core/lib/Drupal/Core/Form/FormValidator.php(270): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState)) #9 /home/dgz75/www/core/lib/Drupal/Core/Form/FormValidator.php(119): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'field_config_ed...') #10 /home/dgz75/www/core/lib/Drupal/Core/Form/FormBuilder.php(571): Drupal\Core\Form\FormValidator->validateForm('field_config_ed...', Array, Object(Drupal\Core\Form\FormState)) #11 /home/dgz75/www/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('field_config_ed...', Array, Object(Drupal\Core\Form\FormState)) #12 /home/dgz75/www/core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\field_ui\Form\FieldConfigEditForm), Object(Drupal\Core\Form\FormState)) #13 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #14 /home/dgz75/www/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #15 /home/dgz75/www/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #16 /home/dgz75/www/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #17 /home/dgz75/www/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #18 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #19 /home/dgz75/www/vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array) #20 /home/dgz75/www/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #21 /home/dgz75/www/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /home/dgz75/www/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /home/dgz75/www/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /home/dgz75/www/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /home/dgz75/www/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /home/dgz75/www/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /home/dgz75/www/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /home/dgz75/www/core/lib/Drupal/Core/DrupalKernel.php(652): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 /home/dgz75/www/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #30 {main}.
Severity Error
Hostname 138.201.254.28
πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States frederickjh The Big Island of Hawai'i

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @Daniel Kulbe tests now fail. In #40 they worked. And I think it would be better to have this as MR.
    Did you check the results using config_inspector? Is the config fine now?

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Updating the title and setting the priority to major, due to the wrong schema

  • First commit to issue fork.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    2 pass, 4 fail
  • @grevil opened merge request.
  • πŸ‡©πŸ‡ͺGermany Grevil

    Switching to issue fork workflow.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    7 pass
  • Status changed to Needs review over 1 year ago
  • πŸ‡©πŸ‡ͺGermany Grevil

    Schema looks good and tests should be fixed now! I get 1 deprecation error and a few deprecation notices, when running the tests locally under Drupal 10. Jenkins might have them all green, since we still use D9.5 + PHP 7.4 for the automated testing environment.

    @berdir, could you add / adjust automated testing using php 8+ and Drupal 10? I'll work on πŸ› Fix deprecation notices RTBC , to quickly resolve the deprecation problems.

    Please review!

  • πŸ‡©πŸ‡ͺGermany Grevil

    All tests are green!

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks @Grevil! MR!12 Corrections like #38 are resolved now.
    Still, this seems to need additional tests as of #45, I think. I'll leave this "Needs review" for @Berir and others to eventually review the final implementation already, but guess it needs to go back to "Needs work" for tests. Anyone to take this over the finish line?

  • Status changed to RTBC about 1 year ago
  • πŸ‡§πŸ‡ͺBelgium borisson_ Mechelen, πŸ‡§πŸ‡ͺ

    Posted a small remark on the merge request that we can use conditions as well, but that should not be needed to land this, I'm not sure how many tests we need.

    We could use the schema check trait to test the schema during tests, but that is not yet completely usable by contrib yet as far as I know. Because of that I think we can rtbc this already, even without tests, and core soon will help us do this better.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    Patch Failed to Apply
Production build 0.71.5 2024