Fatal Error - too few arguments MetatagManager

Created on 22 March 2022, over 2 years ago
Updated 9 January 2024, 11 months ago

Problem/Motivation

Drush commands fail with the following output:

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Drupal\metatag\MetatagManager::__construct(), 5 passed in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 and exactly 6 expected in /app/web/modules/contrib/metatag/src/MetatagManager.php:89
Stack trace:
#0 /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php(262): Drupal\metatag\MetatagManager->__construct(Object(Drupal\metatag\MetatagGroupPluginManager), Object(Drupal\metatag\MetatagTagPluginManager), Object(Drupal\metatag\MetatagToken), Object(Drupal\Core\Logger\LoggerChannelFactory), Object(Drupal\Core\Entity\EntityTypeManager))
#1 /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'metatag.manager')
#2 /app/web/modules/contrib/metatag/metatag_views/src/Plugin/views/display_extender/MetatagDisplayExtender.php(57): Drupal\Component\DependencyInjection\Container->get('metatag.manager')
#3 /app/web/core/lib/Dru in /app/web/modules/contrib/metatag/src/MetatagManager.php on line 89

Steps to reproduce

Upgrade to latest drupal core (9.3.9)
Run a drush command (ie: `drush cr`)

πŸ› Bug report
Status

Postponed: needs info

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States erier

Live updates comments and jobs are added and updated live.
  • PHP 8.0

    The issue particularly affects sites running on PHP version 8.0.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany thomaswalther Rhein-Main Area

    Version dev worked for me. But not the 1.22 also with cleared cached before update.

    I had installed version 1.19 (D9.3.3 with php7.4) and update to 1.22 (D9.5.5 with php 8.1.14)

    This is my error. Maybe it will help you as info:

    ArgumentCountError: Too few arguments to function Drupal\metatag\MetatagManager::__construct(), 5 passed in /webroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and exactly 9 expected in /webroot/modules/metatag/src/MetatagManager.php on line 119 #0 /webroot/core/lib/Drupal/Component/DependencyInjection/Container.php(259): Drupal\metatag\MetatagManager->__construct()
    #1 /webroot/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService()
    #2 /webroot/core/lib/Drupal.php(197): Drupal\Component\DependencyInjection\Container->get()
    #3 /webroot/modules/metatag/metatag.module(483): Drupal::service()
    #4 /webroot/modules/metatag/metatag.module(451): metatag_get_tags_from_route()
    #5 [internal function]: metatag_preprocess_html()
    #6 /webroot/core/lib/Drupal/Core/Theme/ThemeManager.php(287): call_user_func_array()
    #7 /webroot/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
    #8 /webroot/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
    #9 /webroot/core/lib/Drupal/Core/Render/Renderer.php(148): Drupal\Core\Render\Renderer->render()
    #10 /webroot/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
    #11 /webroot/core/lib/Drupal/Core/Render/Renderer.php(149): Drupal\Core\Render\Renderer->executeInRenderContext()
    #12 /webroot/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php(66): Drupal\Core\Render\Renderer->renderRoot()
    #13 /webroot/core/lib/Drupal/Core/ProxyClass/Render/BareHtmlPageRenderer.php(76): Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage()
    #14 /webroot/core/authorize.php(197): Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage()
    #15 {main}
    
    
  • Status changed to Closed: duplicate over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    If the problem doesn't happen in the dev version then this seems to be a problem that was fixed by another issue.

  • Status changed to Active about 1 year ago
  • πŸ‡·πŸ‡ΈSerbia milovan

    Hello,
    Drupal 9.5.11
    Metatag 2.0.0
    PHP 8.1.18

    ArgumentCountError: Too few arguments to function Drupal\metatag\MetatagManager::__construct(), 9 passed in /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and exactly 10 expected in Drupal\metatag\MetatagManager->__construct() (line 131 of /var/www/html/docroot/modules/contrib/metatag/src/MetatagManager.php)

    The same issue appeared on Prod on Acquia Cloud env. An additional flush cache made it go away.
    I will test it with PHP 8.2 as well.

    I can't find a duplicate issue for this ticket, so I am reopening it. In case I missed the duplicated issue, please let me know and I apologise in advance.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    PHP version tags show the first version with the problem. Bugs are always against a development branch.

  • Status changed to Postponed: needs info about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    I'm petty certain this problem stems from the previous version of the service definition being cached somewhere, and the codebase change confused it. I recommend reloading the caches and, if necessary, restart the web server or PHP service as applicable, that should resolve it.

    If a bug can be identified beyond this service caching problem, please let me know, but for now I'm going to leave this as postponed until something more solid is provided.

  • πŸ‡©πŸ‡ͺGermany marcoka

    I updated to mettag 2 and the matching schema org module using the composer command that was referenced in the update log.
    Site is complete broken now.

    • drush cr has been done
    • complete restart of http server
    • complete system reboot
    • drush updb has been run

    What caches could be cleaned else?
    I have xdebug running. If i get some hints i can provide more information.

    Mon Nov 20 14:29:40.710693 2023] [php:notice] [pid 6912] [client 127.0.0.1:59434] Uncaught PHP Exception ArgumentCountError: "Too few arguments to function Drupal\\metatag\\MetatagManager::__construct(), 9 passed in /srv/http/WORKSPACE_DRUPAL/EIGENE_PROJEKTE/PRODUCT_DISTRI_D12/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and exactly 10 expected" at /srv/http/WORKSPACE_DRUPAL/EIGENE_PROJEKTE/PRODUCT_DISTRI_D12/web/modules/contrib/metatag/src/MetatagManager.php line 131

  • Status changed to Active 12 months ago
  • πŸ‡©πŸ‡ͺGermany thomaswalther Rhein-Main Area

    Update via Backend with Drupal 9.3.9 from Metatag 8.x-1.19 to 8.x-1.26 I got this error:

    ArgumentCountError: Too few arguments to function Drupal\metatag\MetatagManager::__construct(), 5 passed in /web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 and exactly 9 expected in Drupal\metatag\MetatagManager->__construct() (Zeile 119 in /web/modules/metatag/metatag/src/MetatagManager.php)
    #0 /web/core/lib/Drupal/Component/DependencyInjection/Container.php(262): Drupal\metatag\MetatagManager->__construct(
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @thomaswalther try clearing caches, might help!

  • Status changed to Postponed: needs info 12 months ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • πŸ‡¦πŸ‡·Argentina gerzenstl Resistencia

    I'm getting this error and it happens randomly.

    I can solve it by flushing the cache, but then after a couple of hours it happens again.

    My site is using:
    Drupal 9.5.11
    metatag 2.0.0

    PHP 8.1.27

Production build 0.71.5 2024