The website encountered an unexpected error. Try again later.

ArgumentCountError: Too few arguments to function Drupal\Core\Form\ConfigFormBase::__construct(), 1 passed in /var/www/html/web/modules/contrib/configure_contextual_links/src/Form/ContextualLinkSettingsForm.php on line 32 and exactly 2 expected in Drupal\Core\Form\ConfigFormBase->__construct() (line 44 of core/lib/Drupal/Core/Form/ConfigFormBase.php).
Drupal\configure_contextual_links\Form\ContextualLinkSettingsForm->__construct() (Line: 40)
Drupal\configure_contextual_links\Form\ContextualLinkSettingsForm::create() (Line: 36)
Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (Line: 48)
Drupal\Core\Controller\HtmlFormController->getFormObject() (Line: 58)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 634)
Drupal\Core\Render\Renderer::Drupal\Core\Render\{closure}()
Fiber->start() (Line: 635)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 118)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 92)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 745)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Comments

3eidoz created an issue. See original summary.

3eidoz’s picture

I can see the issue clearly. In Drupal core's ConfigFormBase, the __construct() method was updated to require two parameters:

ConfigFactoryInterface $config_factory
TypedConfigManagerInterface $typedConfigManager

However, the configure_contextual_links module's ContextualLinkSettingsForm is only passing one argument (the $config_factory) to the parent constructor at line 32.

This is a compatibility issue with the newer version of Drupal core. I need to fix this by:

  1. Adding the TypedConfigManagerInterface parameter to the constructor
  2. Passing it to the parent constructor
  3. Updating the create() method to inject this dependency

Let me fix this:

Edit ContextualLinkSettingsForm.php
Added 1 line

Edit ContextualLinkSettingsForm.php
Added 2 lines

Edit ContextualLinkSettingsForm.php
Added 1 line

I've fixed the compatibility issue with the configure_contextual_links module. The changes I made:

Changes Made

  1. Added the missing import at line 6:
    • Added use Drupal\Core\Config\TypedConfigManagerInterface;
  2. Updated the constructor at line 34:
    • Added TypedConfigManagerInterface $typed_config_manager as the second parameter
    • Updated the parent constructor call to pass both $config_factory and $typed_config_manager
  3. Updated the create() method at line 45:
    • Added $container->get('config.typed') as the second argument to match the new constructor signature

What This Fixes

The error occurred because Drupal core's ConfigFormBase class was updated to require two parameters in its constructor (ConfigFactoryInterface and TypedConfigManagerInterface), but this contributed module was only passing one. This is a common issue when upgrading Drupal versions.

You should now be able to access the contextual links configuration form without encountering this error. Try refreshing your browser and accessing the form again.

awasson’s picture

Status: Active » Needs review
StatusFileSize
new1.74 KB

@3eidoz, I don't see how that works for version: '1.0.3'.

Have you created a patch or a pull request?

There already is a second parameter, it's just not what the ConfigFormBase class is looking for. We need to add a TypedConfigManagerInterface parameter between the existing two parameters and adjust.

The fix for this is to add the correct second parameter, a TypedConfigManagerInterface parameter and make the existing ContextualLinkManager the third parameter. Then, we update the constructor, the parent constructor and then add the get('config.typed') to the create method.

I have attached a patch that accomplishes this.

Please test this and make sure that it does what it needs to. I think it is working correctly. Everything I have tested works with this patch.

Cheers,
Andrew