Modal window causes the entity browser iFrame to be loaded twice

Created on 4 September 2024, 4 months ago
Updated 7 September 2024, 4 months ago

My project has a custom (entity browser) test that was (sometimes) generating the following PHP warning:

stdClass Object
(
    [wid] => 113
    [uid] => 2
    [type] => php
    [message] => Warning: unlink(/app/web/sites/default/files/languages/nl_cCWBVC-rjV8Sfik91b5hVfX8SMerdGGC_i51RHX9jjo.js): No such file or directory in Drupal\Core\File\FileSystem->unlink() (line 124 of /app/web/core/lib/Drupal/Core/File/FileSystem.php) #0 /app/web/core/includes/bootstrap.inc(164): _drupal_error_handler_real()
#1 [internal function]: _drupal_error_handler()
#2 /app/web/core/lib/Drupal/Core/File/FileSystem.php(124): unlink()
#3 /app/web/core/lib/Drupal/Core/StreamWrapper/LocalStream.php(304): Drupal\Core\File\FileSystem->unlink()
#4 [internal function]: Drupal\Core\StreamWrapper\LocalStream->unlink()
#5 /app/web/core/lib/Drupal/Core/File/FileSystem.php(124): unlink()
#6 /app/web/core/lib/Drupal/Core/File/FileSystem.php(324): Drupal\Core\File\FileSystem->unlink()
#7 /app/web/core/modules/locale/locale.module(1273): Drupal\Core\File\FileSystem->delete()
#8 /app/web/core/modules/locale/locale.module(548): _locale_rebuild_js()
#9 /app/web/core/modules/locale/locale.module(486): locale_js_translate()
#10 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(545): locale_js_alter()
#11 /app/web/core/lib/Drupal/Core/Asset/AssetResolver.php(285): Drupal\Core\Extension\ModuleHandler->alter()
#12 /app/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(328): Drupal\Core\Asset\AssetResolver->getJsAssets()
#13 /app/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(165): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAssetLibraries()
#14 /app/web/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php(97): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments()
#15 /app/web/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php(45): Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor->processAttachments()
#16 [internal function]: Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond()
#17 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#18 /app/vendor/symfony/http-kernel/HttpKernel.php(214): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#19 /app/vendor/symfony/http-kernel/HttpKernel.php(202): Symfony\Component\HttpKernel\HttpKernel->filterResponse()
#20 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#21 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#22 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#23 /app/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#24 /app/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#25 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#26 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#27 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#28 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#29 /app/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#30 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#31 @main.
    [severity] => 4
    [link] => 
    [location] => http://nginx:8080/entity-browser/modal/table_multi?original_path=%2Fnode%2F18%2Fedit&uuid=146b44c0cfe81f735dc424e58267d2ce420d4672
    [referer] => http://nginx:8080/node/18/edit
    [hostname] => 172.19.0.5
    [timestamp] => 1724678925
)

I digged a little further in what's causing this and I found out the entity browser iFrame is actually loaded twice. The first load is quickly aborted (results in a 499 in Nginx), after which the same request is launched again:

The entity browser URL is opened through an iFrame. The way (AJAX) dialogs in Drupal seem to work is that the HTML received through the AJAX-request is first added to the <body>-element (see ), after which jQuery dialog functionality kicks in (see https://git.drupalcode.org/project/drupal/-/blob/11.x/core/misc/dialog/d...) which first removes it from the -element - stopping the iFrame from loading (= browser aborts the ongoing request). The AJAX response content (containing the entity browser iFrame) is then added again to the <body>-element, (wrapped with dialog-specific HTML elements), which makes the iFrame start loading again.

Although not that of a big deal, I'm wondering if this is something that can be improved upon?

πŸ› Bug report
Status

Active

Version

2.0

Component

Display plugins

Created by

πŸ‡§πŸ‡ͺBelgium rp7

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

Comments & Activities

Production build 0.71.5 2024