ArgumentCountError: Too few arguments (none) to constructor

Created on 26 August 2024, 4 months ago

Problem/Motivation

This error is being thrown sporadically. Here's the output, though I'll note that sometimes the call stack goes through PageCache->pass() instead of PageCache->fetch():

ArgumentCountError: Too few arguments to function Drupal\views_show_more\EventSubscriber\ShowMoreEventSubscriber::__construct(), 0 passed in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and exactly 1 expected in Drupal\views_show_more\EventSubscriber\ShowMoreEventSubscriber->__construct() (line 27 of /app/web/modules/contrib/views_show_more/src/EventSubscriber/ShowMoreEventSubscriber.php)
#0 /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php(259): Drupal\views_show_more\EventSubscriber\ShowMoreEventSubscriber->__construct()
#1 /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService()
#2 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(136): Drupal\Component\DependencyInjection\Container->get()
#3 /app/vendor/symfony/http-kernel/HttpKernel.php(202): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#4 /app/vendor/symfony/http-kernel/HttpKernel.php(190): Symfony\Component\HttpKernel\HttpKernel->filterResponse()
#5 /app/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#6 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#7 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#8 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#9 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch()
#10 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup()
#11 /app/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle()
#12 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#13 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#14 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#15 /app/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#16 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#17 {main}

Steps to reproduce

I haven't been able to reliably reproduce. I think it's either an incomplete cache rebuild that doesn't inject the Renderer service into the views_show_more.event_subscriber service and leaves cache dirty until it gets properly rebuilt, or there's an issue with the way Symfony parses services.yml files when the tags property comes before the arguments property where it sometimes doesn't get to parsing the arguments property.

Proposed resolution

Reorder the tags and arguments properties in views_show_more.services.yml

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States sethfisher

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

Comments & Activities

  • Issue created by @sethfisher
  • πŸ‡ΊπŸ‡ΈUnited States sethfisher

    Patch that reverses the order of tags and arguments in views_show_more.services.yml

  • Status changed to Needs review 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States sethfisher
  • πŸ‡ΊπŸ‡ΈUnited States sethfisher

    BTW as to why I think this about the order of the properties in the services definition and the Symfony parser: I went through all the services in all the modules in core and close to 200 contrib modules, and almost all of them have arguments before tags. The few that didn't were either cache services, drush, or from modules that would rarely or never have their services loaded on the site I'm seeing the issue. That would explain why I only see the issue with this module.

Production build 0.71.5 2024