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
- Create a node containing a text area field with a text format that has a CKEditor config with the "Insert media" button (plugin) enabled.
- Click the "Insert media" button in the CKeditor to load the media library
- Click the "Open IntelligenceBank Browser"
- Select and download an image from the DAM
- Select the downloaded image in the Media library
- Save the node
- Find warnings in log
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #3
joegraduateComment #4
joegraduateComment #5
trackleft2Tested in tugboat, no errors in the log when I embedded a media item via the media browser using the intelligence bank integration.
Comment #6
vlad.dancer@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.
Comment #7
vlad.dancerOh, I just realized that tugboat deployed Drupal with MR applied there. Ok, I need to test it on gitpod, without the MR.
Comment #9
vlad.dancerOk, looks like there is no need to store an empty data inside $widget_context['ib_dam_media']:
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!
Comment #10
joegraduateThanks for the quick response @vlad.dancer!