ArgumentCountError: Too few arguments to function Drupal\metatag\MetatagManager::__construct(), 4 passed in /public_html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 280 and exactly 5 expected in /public_html/modules/metatag/src/MetatagManager.php on line 42 #0 /public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(280): Drupal\metatag\MetatagManager->__construct(Object(Drupal\metatag\MetatagGroupPluginManager), Object(Drupal\metatag\MetatagTagPluginManager), Object(Drupal\metatag\MetatagToken), Object(Drupal\redirect_404\Render\Redirect404LogSuppressor))
#1 /public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'metatag.manager')
#2 /public_html/core/lib/Drupal.php(158): Drupal\Component\DependencyInjection\Container->get('metatag.manager')
#3 /public_html/modules/metatag/metatag.module(333): Drupal::service('metatag.manager')
#4 /public_html/modules/metatag/metatag.module(114): metatag_get_tags_from_route()
#5 /public_html/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(297): metatag_page_attachments(Array)
#6 /public_html/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(273): Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array)
#7 /public_html/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(117): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#8 /public_html/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#9 /public_html/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#10 /public_html/vendor/symfony/http-kernel/HttpKernel.php(149): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent))
#11 /public_html/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#12 /public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /public_html/core/lib/Drupal/Core/DrupalKernel.php(656): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#21 {main}

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gmaxwelled created an issue. See original summary.

fomenkoandrey’s picture

the same at 3 sites

The website encountered an unexpected error. Please try again later.
ArgumentCountError: Too few arguments to function Drupal\metatag\MetatagManager::__construct(), 4 passed in /home/motokale/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 280 and exactly 5 expected in Drupal\metatag\MetatagManager->__construct() (line 42 of modules/metatag/src/MetatagManager.php).

https://image.prntscr.com/image/5590bc0c5c6846f28cc6d91799b19406.png

cmwelding’s picture

It crashed the entire site after the update.

DamienMcKenna’s picture

Did you try clearing the site's caches after the update?

DamienMcKenna’s picture

Priority: Major » Critical

Could you please let me know what version of core you're using? 8.3 I presume?

JonathanFontesCaetsu’s picture

Hello DamienMcKenna,

I have 8.3.2. And the issue cross all the "Metatag: *" modules.

fomenkoandrey’s picture

Priority: Critical » Major

3 crashed sites use Drupal 8.3.2

a.henry’s picture

We are facing the same problem after upgrading to 8.x-1.1
Metatag views is not install (only metatag), but in our case it is webprofiler 1.0-rc2 that is
causing the problem.

Argument 5 passed to Drupal\metatag\MetatagManager::__construct() must be an instance of Drupal\Core\Entity\EntityTypeManager, instance of Drupal\webprofiler\Entity\EntityManagerWrapper given, called in /home/dcl2y/www/core/lib/Drupal/Component/DependencyInjection/Container.php on line 284 and defined in Drupal\metatag\MetatagManager->__construct() (line 46 of /home/dcl2y/www/sites/default/modules/metatag/src/MetatagManager.php) 

Uninstalling web profiler fix the error.
Tried it on simplytest.me with only metatag and web profiler (devel) installed.
The error message is not the exactly the same as the one that gmaxwelled is having, and not the same as in #2883088.

Bandit2300’s picture

Idem. Site crashed after update !!!

JonathanFontesCaetsu’s picture

I can confirm, the problem is related with web profile, after uninstall webprofile and install metatag, this work perfectly.

nickvanboven’s picture

Idem. Site crashed after update !!! only when webprofiler is enabled

TypeError: Argument 5 passed to Drupal\metatag\MetatagManager::__construct() must be an instance of Drupal\Core\Entity\EntityTypeManager, instance of Drupal\webprofiler\Entity\EntityManagerWrapper given, called in /var/www/scheldemond/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 284 in /var/www/scheldemond/web/modules/contrib/metatag/src/MetatagManager.php on line 42 
a.henry’s picture

Here is a patch to use EntityTypeManagerInterface instead of EntityTypeManager in the constructor.

a.henry’s picture

Status: Active » Needs review
DamienMcKenna’s picture

Is anyone having this error and does *not* have the WebProfiler module installed?

JonathanFontesCaetsu’s picture

Hello,

In my case after uninstall webprofile module, the issue disappear. So, i think the issue is related with webprofile.

Best Regards,
Jonathan Fontes
CAETSU

cmwelding’s picture

I had not installed WebProfiler and Devel module when the error occurred.

DamienMcKenna’s picture

Here's a tests-only patch to see what happens with Devel and then WebProfiler are enabled.

Robardi56’s picture

I have this issue on a fresh install of drupal aquia lightning (Drupal core 8.3.2 ) I downloaded today to evaluate.
First thing I did was update the metatag module that was the only one marked as outdated.

TypeError: Argument 5 passed to Drupal\metatag\MetatagManager::__construct() must be an instance of Drupal\Core\Entity\EntityTypeManager, none given, called in /home/uniqueas/**/aa/core/lib/Drupal/Component/DependencyInjection/Container.php on line 280 in Drupal\metatag\MetatagManager->__construct() (line 42 of /home/uniqueas/**/aa/profiles/lightning/modules/contrib/metatag/src/MetatagManager.php) #0

Status: Needs review » Needs work

The last submitted patch, 17: metatag-n2882954-16.tests-only.patch, failed testing.

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

FYI it seems that WebProfiler doesn't work with Drupal core 8.4.x anyway due to its change to Symfony 3 instead of 2.x, see #2879214: Support for Drupal 8.4.x using Symfony 3 in webprofiler. This means I'll have to update the automated tests to check core 8.3.x first instead of 8.4.x.

Status: Needs review » Needs work

The last submitted patch, 20: metatag-n2882954-20.patch, failed testing.

DamienMcKenna’s picture

As expected, the tests fail with 8.4. I've ran the tests locally with 8.3 and they work, so I've updated the module's configuration to use it by default and I'm rerunning the tests with it.

JonathanFontesCaetsu’s picture

I think my Drupal Core version is 8.3.x (something). And i have this issue

DamienMcKenna’s picture

The 8.3 tests are failing because it isn't downloading Devel.

  • DamienMcKenna committed ba4d7ee on 8.x-1.x
    Issue #2882954 by DamienMcKenna: Added Devel as a test dependency.
    
DamienMcKenna’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Status: Needs work » Needs review
FileSize
3.34 KB

Without the info file changes.

DamienMcKenna’s picture

Ok, this is great! All tests are green with 8.3.

DamienMcKenna’s picture

Status: Needs review » Fixed
Parent issue: » #2563617: Plan for Metatag 8.x-1.2 release

Ok, I'm going to commit this as-is and I'll add a note to the 1.1 release notes about the problem.

Thanks everyone!

fomenkoandrey’s picture

Version: 8.x-1.x-dev » 8.x-1.1
Status: Fixed » Needs review

Does this patch in the dev version?

DamienMcKenna’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Status: Needs review » Fixed

Yes, he patch is included in the dev version.

leoraw’s picture

I just got this error when I tried the update:
The website encountered an unexpected error. Please try again later.
TypeError: Argument 5 passed to Drupal\metatag\MetatagManager::__construct() must be an instance of Drupal\Core\Entity\EntityTypeManager, none given, called in /srv/bindings/c74fea21966541d39e9c7f99763e0015/code/core/lib/Drupal/Component/DependencyInjection/Container.php on line 280 in Drupal\metatag\MetatagManager->__construct() (line 42 of modules/metatag/src/MetatagManager.php).

======
And this appeared on the screen:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /core/authorize.php/core/authorize.php?batch=1&id=3520&op=do_nojs&op=do
StatusText: OK
ResponseText: TypeError: Argument 5 passed to Drupal\metatag\MetatagManager::__construct() must be an instance of Drupal\Core\Entity\EntityTypeManager, none given, called in /srv/bindings/c74fea21966541d39e9c7f99763e0015/code/core/lib/Drupal/Component/DependencyInjection/Container.php on line 280 in Drupal\metatag\MetatagManager->__construct() (line 42 of /srv/bindings/c74fea21966541d39e9c7f99763e0015/code/modules/metatag/src/MetatagManager.php).
===========
Not using WebProfiler.

a.henry’s picture

Tested the update with update manager on a fresh install (metatag 1.0 -> 1.1).
Wasn't able to reproduce.

cmwelding’s picture

FileSize
20.01 KB

Tested the update Metatag 1.0 -> 1.1 on a fresh install at simplytest.me. Updated failed with following error. See the attached image.

Error installing / updating

File Transfer failed, reason: Cannot remove file /home/dc6y9/www/sites/default/modules/metatag/metatag_verification/src/Tests/MetatagVerificationTagsTest.php.

DamienMcKenna’s picture

@cmwelding: I don't think that error has anything to do with Metatag.

arknoll’s picture

I tested patch https://www.drupal.org/files/issues/metatag-n2882954-28.patch and it did not work for me.

Here are my steps:

1. Using Lightning
2. Add patch file to composer
3. Update lightning to test next release: composer update acquia/lightning --with-dependencies
4. patch applies
5. Visit site and receive error:

The website encountered an unexpected error. Please try again later.
Recoverable fatal error: Argument 5 passed to Drupal\metatag\MetatagManager::__construct() must implement interface Drupal\Core\Entity\EntityTypeManagerInterface, none given, called in /var/www/canary/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 280 and defined in Drupal\metatag\MetatagManager->__construct() (line 46 of modules/contrib/metatag/src/MetatagManager.php).
Drupal\metatag\MetatagManager->__construct(Object, Object, Object, Object) (Line: 280)
Drupal\Component\DependencyInjection\Container->createService(Array, 'metatag.manager') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('metatag.manager') (Line: 158)
Drupal::service('metatag.manager') (Line: 333)
metatag_get_tags_from_route() (Line: 114)
metatag_page_attachments(Array) (Line: 297)
Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array) (Line: 273)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 207)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 121)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 75)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

6. Run drush cr and the error is gone

gustavo.marcante’s picture

Sorry, I'm a Drupal newbie, and I got the same error.
I got it twice, updating Drupal just after fresh installing of two different distributions: OpenEdu (based on Acqua Lightning) and Varbase.

@DamienMcKenna I found webprofiler module in Varbase, but I did't find in Lightning and OpenEdu.
So, maybe this is not the only error.

BEFORE the patch, I could recover with (supposing being at the installation directory):

cd  docroot
drush cr all
composer update   (optional)
cd core
php rebuild.php
cd ..
drush cr all    (again)

But, to avoid happen again, I tried the above patch too.
I don't know if I did right, in composer.json, after

  "extra": {

there are many lines, after the last I put a comma and these:

    "patches": {
      "symfony/web-profiler-bundle": {
      "Drupal fix webprofiler crash": "https://www.drupal.org/files/issues/metatag-n2882954-28.patch"     
      }
    } 

Is it right?

What is said in https://www.drupal.org/project/webprofiler is that webprofiler is deprecated and unsupported.
Sorry to ask, but should not it have been removed from the current versions?

frederico’s picture

@Gustavo, Thanks! You saved me!!! I appreciate you taking time to help the rest of us out. -Frederico

Jorgas’s picture

@Gustavo, thanks a lot.

  • DamienMcKenna committed 69e5295 on 8.x-1.x
    Issue #2882954, #2877737 by DamienMcKenna, René-Marc Simard, a.henry:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.