TypeError: key(): Argument #1 ($array) must be of type array, null given in key() (line 424 of modules\contrib\entity_browser\src\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget.php)

Created on 15 April 2024, over 1 year ago

Steps to reproduce

TypeError: key(): Argument #1 ($array) must be of type array, null given in key() (line 424 of modules\contrib\entity_browser\src\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget.php).

Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget::processEntityBrowser(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 1013)
Drupal\Core\Form\FormBuilder->doBuildForm('question_entity_text_question_add_form', Array, Object) (Line: 1076)
Drupal\Core\Form\FormBuilder->doBuildForm('question_entity_text_question_add_form', Array, Object) (Line: 1076)
Drupal\Core\Form\FormBuilder->doBuildForm('question_entity_text_question_add_form', Array, Object) (Line: 1076)
Drupal\Core\Form\FormBuilder->doBuildForm('question_entity_text_question_add_form', Array, Object) (Line: 579)
Drupal\Core\Form\FormBuilder->processForm('question_entity_text_question_add_form', Array, Object) (Line: 325)
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: 32)
Drupal\big_pipe\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: 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)

🐛 Bug report
Status

Active

Version

2.10

Component

Widget plugins

Created by

🇮🇳India jayprakash.kushwah India

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

Merge Requests

Comments & Activities

  • Issue created by @jayprakash.kushwah
  • Assigned to abhishek_virasat
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India abhishek_virasat

    fixed the issue and created Patch.

  • Status changed to Active over 1 year ago
  • 🇮🇳India jayprakash.kushwah India

    entity_browser-3440973.patch patch is working fine.

  • Status changed to RTBC over 1 year ago
  • 🇩🇪Germany sharique

    +1 for RTBC.

  • Status changed to Needs work 12 months ago
  • 🇨🇭Switzerland berdir Switzerland

    This will just silently hide the notice, but the module won't properly work then I think, so needs clearer steps on how to reproduce.

  • 🇨🇦Canada danrod Ottawa

    I got the same error on a fresh Drupal 11.1.4 install:

    1. Added a new image field for the "Article" content type.
    2. In the Form Display Manager, I set that field to use the "Entity Field" widget.
    3. if I try to add an article (/node/add/article) I get the same error.

  • 🇯🇵Japan bassline

    I installed the entity_browser module in Drupal 10.4.5.
    After switching to entity_browser in the content type form display management, I got the same error in the content edit screen.
    After applying the #4 patch, I am now able to edit content on the content edit screen.

  • 🇮🇳India vipin.mittal18 Greater Noida

    I faced the same issue, but applying the patch resolved it and unblocked me from creating content.

  • Merge request !71Check if variable set → (Open) created by vipin.mittal18
  • Pipeline finished with Success
    4 months ago
    Total: 257s
    #474613
  • Status changed to RTBC 2 months ago
  • 🇩🇪Germany michaellenahan

    I got this error, because no entity browser was selected for the field.

    Make sure your entity browser instance is set up correctly:

    admin/config/content/entity_browser

    ... then add the entity browser instance to your field

    See screenshot:
    https://www.drupal.org/files/issues/2025-05-23/2025-05-23-08.59.28-34409...

    admin/structure/types/manage/page/form-display
    No entity browser selected

  • First commit to issue fork.
  • Pipeline finished with Success
    21 days ago
    Total: 255s
    #545361
  • 🇺🇸United States neclimdul Houston, TX

    Ran into this as well. Reviewing the merge request, the two if statements are just approximating an empty check so simplified it.

    Here are the steps I used to recreate this.

    1. Create a media field on a node or paragraph if you don't have one to test. It doesn't seem to matter where it exists.
    2. On the "Manage form display" tab select "autocomplete" for the widget and save.
    3. Now set it back to entity browser and save without expanding the gear and setting up the field.

    Without the patch, at this point two things are broken throwing both an undefined array key warning and a fatal type error.
    1. From the manage fields tab editing the field is broken.
    2. The node form or paragraph addition form seem to also be broken.

    With the patch everything is fine
    1. Manage fields is normal. I don't see any use widget language so this call might not be strictly necessary.
    2. The form "works" but the user is presented with "Entity browser not found. You can select one media item." which would prompt a developer to fix the form display.

  • 🇦🇺Australia jannakha Brisbane!
Production build 0.71.5 2024