Problem/Motivation
On drupal 9.1.4, production.
The following error happened on trying to update certain node outline. I couldn't reproduce it on the other nodes in the same book outline.
TypeError: Argument 2 passed to Drupal\Component\Utility\NestedArray::getValue() must be of the type array, null given, called in /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Field/WidgetBase.php on line 414 in Drupal\Component\Utility\NestedArray::getValue() (line 69 of /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Component/Utility/NestedArray.php)
#0 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Field/WidgetBase.php(414): Drupal\Component\Utility\NestedArray::getValue(Array, NULL)
#1 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(265): Drupal\Core\Field\WidgetBase->flagErrors(Object(Drupal\Core\Field\EntityReferenceFieldItemList), Object(Symfony\Component\Validator\ConstraintViolationList), Array, Object(Drupal\Core\Form\FormState))
#2 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(268): Drupal\Core\Entity\Entity\EntityFormDisplay->flagWidgetsErrorsFromViolations(Object(Drupal\Core\Entity\EntityConstraintViolationList), Array, Object(Drupal\Core\Form\FormState))
#3 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(214): Drupal\Core\Entity\ContentEntityForm->flagViolations(Object(Drupal\Core\Entity\EntityConstraintViolationList), Array, Object(Drupal\Core\Form\FormState))
#4 [internal function]: Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object(Drupal\Core\Form\FormState))
#5 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array)
#6 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormValidator.php(273): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
#7 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'node_book_book_...')
#8 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormBuilder.php(589): Drupal\Core\Form\FormValidator->validateForm('node_book_book_...', Array, Object(Drupal\Core\Form\FormState))
#9 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm('node_book_book_...', Array, Object(Drupal\Core\Form\FormState))
#10 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\book\Form\BookOutlineForm), Object(Drupal\Core\Form\FormState))
#11 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#12 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#13 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#15 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#16 /home4/usrname/drupalsite.tld/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#17 /home4/usrname/drupalsite.tld/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#18 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /home4/usrname/drupalsite.tld/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /home4/usrname/drupalsite.tld/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/DrupalKernel.php(706): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /home4/usrname/drupalsite.tld/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#26 {main}
Steps to reproduce
1. Went to update book outline of certain node/123 clicking on the Outline tab. /node/123/outline
2. node weight was 0. Changed to 15
3. click "Update Book Outline" > the above error.
I cleared cache and tried again. No fix.
I tried changing the weight to other numbers. No fix.
I tested other nodes under same book and all was good with them!
I couldn't find anything different with the problematic node ! all nodes in the outline are same content type.
I went in DB (phpMyAdmin on shared host) and edited the node weight from 0 to 15 and saved.
UPDATE `book` SET `weight` = '15' WHERE `book`.`nid` = 123;
I tried updating again via UI and all went fine this time ! I edited it back to 0 and saved (in UI) ; I then updated it again from 0 to 15 and all went well !
I tried to reproduce it after undoing the DB fix:
I went again to DB and edited it back to 0:
UPDATE `book` SET `weight` = '0' WHERE `book`.`nid` = 123
Tested again doing it from UI and all went fine.