Argument #1 ($values) must be of type array, null given.

Created on 30 November 2023, about 1 year ago

When i try to send privet message to unavailable user or not existing user and click to send message the website encounters the fallowing error TypeError: Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget::massageFormValues(): Argument #1 ($values) must be of type array, null given.
I will post patch soon.

🐛 Bug report
Status

Active

Version

3.0

Component
Database 

Last updated 2 days ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

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

Comments & Activities

  • Issue created by @omaralsaed
  • last update about 1 year ago
    Patch Failed to Apply
  • last update about 1 year ago
    Patch Failed to Apply
  • 🇮🇳India sijumpk

    What do you mean by "send privet message"? Could you update the issue summary with Steps to reproduce this problem.

  • Status changed to Postponed: needs info about 1 year ago
  • 🇳🇿New Zealand quietone

    @omaralsaed, thanks for posting a patch with this issue.

    Steps to reproduce was asked her 6 months ago and none have been provided. That information is needed so we can verify the problem and to write tests.

    Since we need more information to move forward with this issue, I am keeping the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • 🇩🇪Germany jurgenhaas Gottmadingen

    I just came across this same error message and found this issue. My scenario is that we're in an entity edit form (e.g. uploading a new image media entity) which also contains an inline entity form for a custom entity (meta data).

    When either uploading an image in the file field or removing that file afterwards, the Drupal form dispatches an ajax request to handle that.

    Now, we've implemented the hook_inline_entity_form_entity_form_alter which does this:

          /** @var \Drupal\inline_entity_form\InlineFormInterface $handler */
          $handler = \Drupal::entityTypeManager()->getHandler($form['#entity']->getEntityTypeId(), 'inline_form');
          $handler->entityFormSubmit($form, $form_state);
    

    That eventually calls \Drupal\Core\Field\WidgetBase::extractFormValues which works fine for most fields and properties but for an entity reference field, the following line returns the string _none:

      $values = NestedArray::getValue($form_state->getValues(), $path, $key_exists);
    

    Everything following that line expects $values to be an array, but for the entity reference field we received a string.

    Then, on line 505 this calls $values = $this->massageFormValues($values, $form, $form_state); and that throws an exception on PHP 8.2 because the first argument has to be an array,

    I've checked the git logs, and none of that code has changed after 31.7.2014, when Dries committed some changes ;-)

    Maybe this indicates an old issue which only now hits us with safe types in PHP 8.2?

  • If I use the patch #2, everything works fine, the problem is that it then gives me the following error:

    The website encountered an unexpected error. Try again later.
    TypeError: Drupal\Component\Utility\NestedArray::getValue(): Argument #2 ($parents) must be of type array, null given, called in /var/www/ultimatetrekking.com/core/modules/layout_builder/src/Plugin/Block/InlineBlock.php on line 194 in Drupal\Component\Utility\NestedArray::getValue() (line 69 of core/lib/Drupal/Component/Utility/NestedArray.php).
    Drupal\layout_builder\Plugin\Block\InlineBlock->blockSubmit() (Line: 234)
    Drupal\Core\Block\BlockBase->submitConfigurationForm() (Line: 293)
    Drupal\block_field\Plugin\Field\FieldWidget\BlockFieldWidget->massageFormValues() (Line: 505)
    Drupal\Core\Field\WidgetBase->extractFormValues() (Line: 244)
    Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues() (Line: 334)
    Drupal\Core\Entity\ContentEntityForm->copyFormValuesToEntity() (Line: 301)
    Drupal\Core\Entity\EntityForm->buildEntity() (Line: 155)
    Drupal\Core\Entity\ContentEntityForm->buildEntity() (Line: 186)
    Drupal\Core\Entity\ContentEntityForm->validateForm()
    call_user_func_array() (Line: 82)
    Drupal\Core\Form\FormValidator->executeValidateHandlers() (Line: 274)
    Drupal\Core\Form\FormValidator->doValidateForm() (Line: 118)
    Drupal\Core\Form\FormValidator->validateForm() (Line: 593)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 326)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
    Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)

  • 🇦🇺Australia pameeela

    I don't think this meets the critical criteria.

  • 🇪🇸Spain guardiola86

    I'm having the same issue when trying to use field browser on a field.

  • 🇬🇧United Kingdom lexsoft London

    Drupal Version 10.3.10 PHP 8.3.12

    I'm having the same issue as @jurgenhaas has described.

    Have anybody found a fix?

  • 🇬🇧United Kingdom lexsoft London
  • 🇳🇱Netherlands daffie

    This is a problem in the field system. Moving the issue to the field system queue.

Production build 0.71.5 2024