In content add and content type edit page instead for entity browser an error message shows. Its only for some content types, rest of the content types it works fine.
Entity browser not found.

Warning: key() expects parameter 1 to be array, null given in Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget::processEntityBrowser() (line 400 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: 982)
Drupal\Core\Form\FormBuilder->doBuildForm('field_config_edit_form', Array, Object) (Line: 1045)
Drupal\Core\Form\FormBuilder->doBuildForm('field_config_edit_form', Array, Object) (Line: 1045)
Drupal\Core\Form\FormBuilder->doBuildForm('field_config_edit_form', Array, Object) (Line: 1045)
Drupal\Core\Form\FormBuilder->doBuildForm('field_config_edit_form', Array, Object) (Line: 557)
Drupal\Core\Form\FormBuilder->processForm('field_config_edit_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 142)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

version: '8.x-1.3'
We have deleted media contents manually from admin/content

Hope that's the issue, but still it need to be fixed.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deepak_zyxware created an issue. See original summary.

deepakrmklm’s picture

Issue summary: View changes
mattsqd’s picture

I ran into this same issue and did not have time to track down why it happened but it happened after I added a second media field to an entity. For some reason, the Drupal Settings that control the entity browser config are not saved to the field. I opened the manage field page, clicked the gear to edit the settings for the entity browser, then changed anything (I switched between image and entity browser), then saved. The $element['#attached']['drupalSettings']['entity_browser'] was then set for the field and stopped this error.

jjchinquist’s picture

We are using entity_browser 8.x-1.4 and receive the same problem. The node type is "recipe".

    Notice: Undefined index: drupalSettings in Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget::processEntityBrowser() (line 400 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: 993)
    Drupal\Core\Form\FormBuilder->doBuildForm('node_recipe_form', Array, Object) (Line: 1056)
    Drupal\Core\Form\FormBuilder->doBuildForm('node_recipe_form', Array, Object) (Line: 1056)
    Drupal\Core\Form\FormBuilder->doBuildForm('node_recipe_form', Array, Object) (Line: 1056)
    Drupal\Core\Form\FormBuilder->doBuildForm('node_recipe_form', Array, Object) (Line: 557)
    Drupal\Core\Form\FormBuilder->processForm('node_recipe_form', Array, Object) (Line: 314)
    Drupal\Core\Form\FormBuilder->buildForm('node_recipe_form', Object) (Line: 48)
    Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 113)
    Drupal\node\Controller\NodeController->add(Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    call_user_func_array(Object, Array) (Line: 153)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    Warning: key() expects parameter 1 to be array, null given in Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget::processEntityBrowser() (line 400 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: 993)
    Drupal\Core\Form\FormBuilder->doBuildForm('node_recipe_form', Array, Object) (Line: 1056)
    Drupal\Core\Form\FormBuilder->doBuildForm('node_recipe_form', Array, Object) (Line: 1056)
    Drupal\Core\Form\FormBuilder->doBuildForm('node_recipe_form', Array, Object) (Line: 1056)
    Drupal\Core\Form\FormBuilder->doBuildForm('node_recipe_form', Array, Object) (Line: 557)
    Drupal\Core\Form\FormBuilder->processForm('node_recipe_form', Array, Object) (Line: 314)
    Drupal\Core\Form\FormBuilder->buildForm('node_recipe_form', Object) (Line: 48)
    Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 113)
    Drupal\node\Controller\NodeController->add(Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    call_user_func_array(Object, Array) (Line: 153)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

markdorison’s picture

Version: 8.x-1.3 » 8.x-1.x-dev
saurabh.dhariwal’s picture

Status: Active » Needs review
FileSize
962 bytes

Hi All, I review all comments that mentioned above, I also got the same warning on Node Add/edit. Please try with my attached patch, in that tried to remove it. Hope this helps you.

Thanks!.

deepakrmklm’s picture

FileSize
49.15 KB

Patch in #6 is enough to fix the warning issue, as its checking the existence before applying key function.

handkerchief’s picture

#6 works. Could you commit this patch?

sch2’s picture

Still works on 2.5 version. We were seeing this issue on some node edit/create forms.

JasonLuttrell’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Needs review » Reviewed & tested by the community

I can also confirm that the patch in #6 addresses the warnings that were appearing in my logs as well. It applies to the latest version, 2.5. It's RTBC. Thanks.

neclimdul’s picture

Status: Reviewed & tested by the community » Needs work

Ran into this through some weirdness today. Field had been disabled ages ago, widget was broken, something something. No real idea how that field got in the state it was in.

The patch "works" in that it fixes the fatal error and the "Entity browser @browser not found" and related messages from EntityBrowserElement is show in the form. I don't think its correct though. It adds a drupalsetting entry for the uuid ''. Its possible something somewhere else could assume all the keys are valid uuids (because they should be) and break in a similar way.

Instead, the same empty checkout should be used but in an if too skip the entire section. Its pretty self explanatory but it also wouldn't hurt to have a note like "If there is something wrong with the widget, skip processing."

sanoopuio’s picture

adis.handanovic’s picture

Ran into very similar issues and used @sanoopuio's patch. Worked great - thank you for sharing with us!

Berdir’s picture

As #11 said, this should wrap the whole thing in an if statement and possibly also log a warning or something, because the only reason for this that I can see is misconfiguration. An entity browser widget that uses a non-existing entity browser.

Instead of patching it in afterwards, what would make more sense is changing \Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget::formElement(), to check if this browser really exists, and if not, then display a warning/error directly there?

The widget even declares the config dependency, so I really have no idea how so many people end up with such invalid configurations?

DuneBL’s picture

I confirm #12 is doing the job.
This is coming from a non configured entity browser setting

poorva’s picture

FileSize
25.59 KB

After appending the patch, error is gone but looks like patch is not working fine. One weird issue appears which says "entity browser not found".

linichalexey’s picture

@poorva your screenshot says that patch works perfectly fine.

I can confirm that the patch #12 works fine.

@berdir I'm not sure, if others face this issue by adding standard entity reference field via ui, but I faced it while custom entity reference field creation.

Here are the steps to reproduce the issue in my case:

  1. Create custom FieldType plugin which extends EntityReferenceItem
  2. In plugin annotation set "default_widget" to NOT "entity_reference_autocomplete". In my case it was a custom FieldWidget plugin which extends EntityReferenceBrowserWidget
  3. Add a new field in admin panel
  4. Observe the error.

In my case it's clear why I got such an error. Because during field creation entity browser type wasn't set yet, it's set only after complete field creation in form display settings.
But it shouldn't happen during creation of a filed using core field type "entity reference", because its default widget is "entity_reference_autocomplete".

linichalexey’s picture

Status: Needs work » Reviewed & tested by the community
farse’s picture

I'm experiencing same behaviour as https://www.drupal.org/project/entity_browser/issues/2914385#comment-148...

Patch #12 also works for me in solving the ajax error. My problem case was adding a paragraph to a content type that had another paragraph within it (with an image using entity browser). This has solved the issue of the ajax error and the paragraph appears on the page now but when I go to the image it says "Entity browser not found" now.

Only local images are allowed.

I have fixed this now but resaving the widget in the manage form display.

esod’s picture

This bug surfaced when switching the widget from Entity browser to Autocomplete for an unlimited Entity reference taxonomy field. No problem making the switch, but when reloading the node form display, the page fatals. Patch #12 get the node form display printing again.

alexdoma’s picture

comment #19 helps me - resaving the widget in the manage form display

neclimdul’s picture

Status: Reviewed & tested by the community » Needs work

I'm not sure why this is RTBC. One of the maintainers and I both said it should be handled different than the current patch.

To be extra clear, both lines of the processing function need to be inside the if statement to avoid triggering additional bugs.

+++ b/src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php
@@ -466,7 +466,7 @@
     $element['#attached']['drupalSettings']['entity_browser'][$uuid]['selector'] = '#' . $element['#custom_hidden_id'];

This line also needs to not run with an invalid id.

This should be a simple re-roll.

manishdrupaldev’s picture

I have fixed the issue using patch #12
Version: 8.x-2.9
PHP: 8.1.20

danrod’s picture

Patch # 12 works great to me:

- Drupal 10.1.2
- PHP 8.1.5
- Entity Browser 8.x-2.9

acbramley’s picture

Status: Needs work » Needs review
FileSize
915 bytes

Just ran into this myself, similar to #11 it was due to an old, broken field type/widget. Thought I might as well implement what has been asked for and ignored a few times 😅

Orkut Murat Yılmaz’s picture

Status: Needs review » Reviewed & tested by the community

I've tested patch #25 and it is working for me. Thank you all:)

Chris Matthews’s picture

Would be great if this could be merged!

jonas139’s picture

The patch also works for me! Thanks

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs work

this should wrap the whole thing in an if statement and possibly also log a warning or something, because the only reason for this that I can see is misconfiguration

I still don't see this being addressed in the latest version.

chetan 11 made their first commit to this issue’s fork.

chetan 11’s picture

Status: Needs work » Needs review
joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

MR 37 looks good

acbramley’s picture

Status: Reviewed & tested by the community » Needs work

Per #29 we need to log a warning.