[WXT 5.1.0] Warning: Undefined array key "url" in Drupal\Core\Asset\CssCollectionOptimizerLazy->optimizeGroup()

Created on 26 December 2023, 12 months ago
Updated 27 December 2023, 12 months ago

Problem/Motivation

I'm just testing the WxT 5.1.0 release, and I am getting this odd issue when loading the home page:

Warning: Undefined array key "url" in Drupal\Core\Asset\CssCollectionOptimizerLazy->optimizeGroup() (line 160 of /var/www/html/html/core/lib/Drupal/Core/Asset/CssCollectionOptimizerLazy.php)
#0 /var/www/html/html/core/includes/bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/h...', 160)
#1 /var/www/html/html/core/lib/Drupal/Core/Asset/CssCollectionOptimizerLazy.php(160): _drupal_error_handler(2, 'Undefined array...', '/var/www/html/h...', 160)
#2 /var/www/html/html/core/modules/system/src/Controller/AssetControllerBase.php(183): Drupal\Core\Asset\CssCollectionOptimizerLazy->optimizeGroup(Array)
#3 [internal function]: Drupal\system\Controller\AssetControllerBase->deliver(Object(Symfony\Component\HttpFoundation\Request), 'css_TDwCj-VAt4I...')
#4 /var/www/html/html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#5 /var/www/html/html/core/lib/Drupal/Core/Render/Renderer.php(592): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#6 /var/www/html/html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#7 /var/www/html/html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#8 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#10 /var/www/html/html/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /var/www/html/html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /var/www/html/html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /var/www/html/html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/html/html/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/html/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#17 {main}

Steps to reproduce

- Install WxT 5.1.0 on a PHP 8.2 instance, then go to the front page, and then go to any section of the Admin Interface and then go to the front page again.

Proposed resolution

It seem like the issue is triggered by some external libraries not having the Library License URL set in *.libraries.yml files, I see that @joseph.oldstad created a patch to fix that issue 🐛 Incomplete license values will cause a PHP warning in Drupal 10.1 compatibility fix Needs review in the fontawesome module but I am sure there are others with the same issue, and again, as @joseph.oldstad suggested in another issue 🐛 Log an error message when library definitions have a license with no URL defined Needs work , there is a core patch that could fix this, which I tried, and it seems to work so far (needs more testing)

Remaining tasks

- Create a patch for WxT composer.json to include the external patch

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: duplicate

Version

5.1

Component

Code

Created by

🇨🇦Canada danrod Ottawa

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

Comments & Activities

Production build 0.71.5 2024