Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 298686

Warning: Undefined array key 1 in Drupal\Core\Asset\AssetResolver of core\lib\Drupal\Core\Asset\AssetResolver.php

$
0
0

Problem/Motivation

Warning: Undefined array key 1 in Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies() (line 67 of core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php) #0 core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php(67): _drupal_error_handler()
#2 core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php(41): Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies()
#3 core/lib/Drupal/Core/Asset/AssetResolver.php(117): Drupal\Core\Asset\LibraryDependencyResolver->getLibrariesWithDependencies()
#4 core/lib/Drupal/Core/Asset/AssetResolver.php(175): Drupal\Core\Asset\AssetResolver->getLibrariesToLoad()
#5 core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php(149): Drupal\Core\Asset\AssetResolver->getCssAssets()
#6 core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php(117): Drupal\Core\Ajax\AjaxResponseAttachmentsProcessor->buildAttachmentsCommands()
#7 core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php(66): Drupal\Core\Ajax\AjaxResponseAttachmentsProcessor->processAttachments()
#8 [internal function]: Drupal\Core\EventSubscriber\AjaxResponseSubscriber->onResponse()
#9 core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#10 symfony/http-kernel/HttpKernel.php(214): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#11 symfony/http-kernel/HttpKernel.php(202): Symfony\Component\HttpKernel\HttpKernel->filterResponse()
#12 symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#13 core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#14 core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#15 core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#16 core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\Core\StackMiddleware\ContentLength->handle()
#17 core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#18 core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#19 core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#20 core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#21 core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#22 core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#23 index.php(19): Drupal\Core\DrupalKernel->handle()
#24 {main}.

Steps to reproduce

  1. With a Views page with "Use AJAX" enabled:
  2. Bare minimum query parameters: https://example.org/views/ajax?ajax_page_state[libraries]=ajax&view_name=example_view

Proposed resolution

A patch has been provided that addresses the issue by checking if the array key exists before accessing it, thereby preventing the warnings.

Currently, the warnings appear because the code attempts to access an array key that may not be set, because they are missing the slash. A patch has been provided that prevents this by checking for the existence of the key before accessing it.

Alternatively, instead of suppressing the warning, we could throw a RuntimeException when this occurs, triggering a 4xx client error. This would indicate that the request was invalid rather than failing silently, making it clear that unexpected input has been provided.

Original Issue Summary

•	Warning: Undefined array key 1 in Drupal\Core\Asset\AssetResolver->getCssAssets() (line 133 of core\lib\Drupal\Core\Asset\AssetResolver.php).
•	Warning: Undefined array key 1 in Drupal\Core\Asset\AssetResolver->getJsAssets() (line 239 of core\lib\Drupal\Core\Asset\AssetResolver.php).
•	Warning: Undefined array key 1 in Drupal\Core\Asset\AssetResolver->getJsAssets() (line 251 of core\lib\Drupal\Core\Asset\AssetResolver.php).
•	Warning: Undefined array key 1 in Drupal\Core\Asset\AssetResolver->getJsSettingsAssets() (line 199 of core\lib\Drupal\Core\Asset\AssetResolver.php).

Viewing all articles
Browse latest Browse all 298686


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>