Problem/Motivation

The following PHP warnings are logged after using the "Insert Media" CKEditor button (plugin) to access the DAM by way of the Media Library and add an image:

Warning: Undefined array key "field_name" in Drupal\ib_dam_media\Form\MediaLibraryIbDamBrowserForm->buildForm() (line 194 of /src/web/modules/contrib/intelligencebank/modules/ib_dam_media/src/Form/MediaLibraryIbDamBrowserForm.php)
#0 /src/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 /src/web/modules/contrib/intelligencebank/modules/ib_dam_media/src/Form/MediaLibraryIbDamBrowserForm.php(194): _drupal_error_handler()
#2 [internal function]: Drupal\ib_dam_media\Form\MediaLibraryIbDamBrowserForm->buildForm()
#3 /src/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array()
#4 /src/web/core/lib/Drupal/Core/Form/FormBuilder.php(284): Drupal\Core\Form\FormBuilder->retrieveForm()
#5 /src/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#6 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#7 /src/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#8 /src/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /src/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#10 /src/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#11 /src/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /src/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#13 /src/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#14 /src/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#15 /src/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#16 /src/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#17 /src/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#18 /src/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#19 /src/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#20 /src/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#21 /src/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#22 /src/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#23 /src/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#24 /src/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#25 {main}
Warning: Undefined array key "entity_type_id" in Drupal\ib_dam_media\Form\MediaLibraryIbDamBrowserForm->buildForm() (line 195 of /src/web/modules/contrib/intelligencebank/modules/ib_dam_media/src/Form/MediaLibraryIbDamBrowserForm.php)
...
Warning: Undefined array key "bundle" in Drupal\ib_dam_media\Form\MediaLibraryIbDamBrowserForm->buildForm() (line 196 of /src/web/modules/contrib/intelligencebank/modules/ib_dam_media/src/Form/MediaLibraryIbDamBrowserForm.php)
...

Steps to reproduce

  1. Create a node containing a text area field with a text format that has a CKEditor config with the "Insert media" button (plugin) enabled.
  2. Click the "Insert media" button in the CKeditor to load the media library
  3. Click the "Open IntelligenceBank Browser"
  4. Select and download an image from the DAM
  5. Select the downloaded image in the Media library
  6. Save the node
  7. Find warnings in log

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

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:

Comments

joegraduate created an issue. See original summary.

joegraduate’s picture

Assigned: joegraduate » Unassigned
Status: Active » Needs review
joegraduate’s picture

Issue summary: View changes
trackleft2’s picture

Status: Needs review » Reviewed & tested by the community

Tested in tugboat, no errors in the log when I embedded a media item via the media browser using the intelligence bank integration.

vlad.dancer’s picture

Status: Reviewed & tested by the community » Active

@joegraduate I can't reproduce it with steps defined in issue's description. Check it here https://mr18-ofex2zwrcgdavguzjeqiezzieztdtign.tugboatqa.com/node/1 . No errors found in db log https://mr18-ofex2zwrcgdavguzjeqiezzieztdtign.tugboatqa.com/admin/report...

What additional steps did you do to get such errors? Which Drupal, module, php versions are you using? Have you configured settings here admin/config/services/ib_dam/media ?

BTW: "Select the downloaded image in the Media library" step is not necessary because after selecting asset in DAM modal it will be automatically downloaded and preselected in media modal.

vlad.dancer’s picture

Oh, I just realized that tugboat deployed Drupal with MR applied there. Ok, I need to test it on gitpod, without the MR.

vlad.dancer’s picture

Status: Active » Fixed

Ok, looks like there is no need to store an empty data inside $widget_context['ib_dam_media']:

"field" => array:3 [
    "name" => null
    "entity_type_id" => null
    "entity_bundle_id" => null
  ]

when modal has been opened from CKEditor.

For now I'm accepting MR and put into my todo list optimising this case.

Thank for heads up!

joegraduate’s picture

Thanks for the quick response @vlad.dancer!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.