Warning: Undefined array key "visual_default_view_mode" when upgrading from D9 to D10

Created on 4 June 2024, 6 months ago
Updated 6 August 2024, 4 months ago

Steps

  • Drupal 9 to Drupal 10
  • Module from 1.1 to 1.4
  • Head to /admin/config/content/diff/general
Error message
Warning: Undefined array key "visual_default_view_mode" in Drupal\diff\Form\GeneralSettingsForm->buildForm() (line 195 of modules/contrib/diff/src/Form/GeneralSettingsForm.php).
Drupal\diff\Form\GeneralSettingsForm->buildForm(Array, Object, NULL)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('diff_general_settings', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->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: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed solution

Add hook_update() with visual_default_view_mode value

🐛 Bug report
Status

Closed: cannot reproduce

Version

1.0

Component

Code

Created by

🇦🇺Australia VladimirAus Brisbane, Australia

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

Comments & Activities

  • Issue created by @VladimirAus
  • Status changed to Closed: cannot reproduce 6 months ago
  • 🇮🇳India vishal prasad

    hello @VladimirAus I Tried to reproduce the error following the process you have mentioned, but i didn't get this error also the form is working fine to me, either we need more info about how to reproduce this error or there may be some issue with any other module in your peoject, causing this issue,

    Closing it for now.

  • Status changed to Needs review 4 months ago
  • 🇮🇳India arpitk

    I was able to reproduce this. Once you install the module and visit the general setting page you get this warning as the default value for view mode is not set and the array key is missing from the config. Attached patch please review.

  • Status changed to Needs work 4 months ago
  • 🇦🇺Australia acbramley

    The setting is both in default config (config/install/diff.settings) and was set by an update hook.

    The only way I could see to trigger this error is to not run an update hook after upgrading.

    I will need steps to reproduce. Fixes also must be in an MR.

  • 🇮🇳India arpitk

    It is still reproducible after running updb.

  • Status changed to Closed: cannot reproduce 4 months ago
  • 🇦🇺Australia acbramley

    I've followed the steps in the IS and after running database updates there is no error. If you're still getting the error simply save the form to set the config.

Production build 0.71.5 2024