PHP 8.1 compatibility

Created on 31 January 2023, almost 2 years ago
Updated 24 May 2023, over 1 year ago

I'm on php8.1 and get the below error and the website is giving WSOD on both front-end and admin area; (I can only see part of the error from drush)

'Error: Undefined constant "CSS_COMPONENTS" in constant() (line 180 of /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php) #0 /var/www/uydu/web/core/lib/Drupal/Core/Ass'

Feature request
Status

Closed: works as designed

Version

4.0

Component

Code

Created by

🇹🇷Turkey rgnyldz

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

Comments & Activities

  • Issue created by @rgnyldz
  • 🇫🇷France damien laguerre

    I think this is a mistake in the definition of a library.

    The "component" key does not have an S at the end.

    base:
      css:
        component: <---
          css/components/foo.css:
    
    
  • 🇹🇷Turkey rgnyldz

    This only happens when ipless module is enabled. Site opens normal if module is disabled.

    I saw only one similar post about this and it was about the componen(s): definition here as you suggested .

    But inside drupal (9) there are lots of modules still using component: instead of components:

    Below is the full error message I found.

    Error: Undefined constant "CSS_COMPONENTS" in constant() (line 180 of /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php)
    #0 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php(180): constant()
    #1 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php(87): Drupal\Core\Asset\LibraryDiscoveryParser->buildByExtension()
    #2 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php(66): Drupal\Core\Asset\LibraryDiscoveryCollector->getLibraryDefinitions()
    #3 /var/www/uydu/web/core/lib/Drupal/Core/Cache/CacheCollector.php(149): Drupal\Core\Asset\LibraryDiscoveryCollector->resolveCacheMiss()
    #4 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php(149): Drupal\Core\Cache\CacheCollector->get()
    #5 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php(111): Drupal\Core\Asset\LibraryDiscoveryCollector->applyLibrariesExtend()
    #6 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php(66): Drupal\Core\Asset\LibraryDiscoveryCollector->getLibraryDefinitions()
    #7 /var/www/uydu/web/core/lib/Drupal/Core/Cache/CacheCollector.php(149): Drupal\Core\Asset\LibraryDiscoveryCollector->resolveCacheMiss()
    #8 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscovery.php(44): Drupal\Core\Cache\CacheCollector->get()
    #9 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDiscovery.php(58): Drupal\Core\Asset\LibraryDiscovery->getLibrariesByExtension()
    #10 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php(68): Drupal\Core\Asset\LibraryDiscovery->getLibraryByName()
    #11 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php(70): Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies()
    #12 /var/www/uydu/web/core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php(41): Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies()
    #13 /var/www/uydu/web/core/lib/Drupal/Core/Asset/AssetResolver.php(104): Drupal\Core\Asset\LibraryDependencyResolver->getLibrariesWithDependencies()
    #14 /var/www/uydu/web/core/lib/Drupal/Core/Asset/AssetResolver.php(116): Drupal\Core\Asset\AssetResolver->getLibrariesToLoad()
    #15 /var/www/uydu/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(312): Drupal\Core\Asset\AssetResolver->getCssAssets()
    #16 /var/www/uydu/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(158): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAssetLibraries()
    #17 /var/www/uydu/web/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php(94): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments()
    #18 /var/www/uydu/web/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php(45): Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor->processAttachments()
    #19 [internal function]: Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond()
    #20 /var/www/uydu/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
    #21 /var/www/uydu/vendor/symfony/http-kernel/HttpKernel.php(202): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
    #22 /var/www/uydu/vendor/symfony/http-kernel/HttpKernel.php(190): Symfony\Component\HttpKernel\HttpKernel->filterResponse()
    #23 /var/www/uydu/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #24 /var/www/uydu/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
    #25 /var/www/uydu/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #26 /var/www/uydu/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #27 /var/www/uydu/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #28 /var/www/uydu/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #29 /var/www/uydu/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #30 /var/www/uydu/web/modules/contrib/remove_http_headers/src/StackMiddleware/RemoveHttpHeadersMiddleware.php(49): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #31 /var/www/uydu/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle()
    #32 /var/www/uydu/web/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle()
    #33 /var/www/uydu/web/index.php(19): Drupal\Core\DrupalKernel->handle()
    #34 {main}

    Also a side note; On my other 8.1 server I use drupal10 and everything works fine with ipless. Not sure if this will be helpfull :)

  • 🇫🇷France damien laguerre

    All possible groups are :

    • base
    • layout
    • component
    • state
    • theme

    In your case, you have a library with "components" group key.
    If your site is working fine with ipless disabled, it means that you have a library like this one:

    base:
      less:
        components: <---
          css/components/foo.css:
    

    You can try something like this and you'll get the same error:

    base:
      css:
        foo: <---
          css/components/foo.css:
    

    'Error: Undefined constant "CSS_FOO" in constant() (line 180 of

    This is not an error of the module, but an error in a lbrary.

  • Status changed to Closed: works as designed over 1 year ago
Production build 0.71.5 2024