Too few arguments error in CertificateLoginSettingsForm constructor

Created on 6 October 2024, 4 months ago

Problem/Motivation

When visiting the module configuration page it throws the following error

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/certificatelogin/src/Form/CertificateLoginSettingsForm.php on line 45 and exactly 2 expected in Drupal\Core\Form\ConfigFormBase->__construct() (line 43 of core/lib/Drupal/Core/Form/ConfigFormBase.php).
Drupal\certificatelogin\Form\CertificateLoginSettingsForm->__construct() (Line: 53)
Drupal\certificatelogin\Form\CertificateLoginSettingsForm::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: 593)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

Using Drupal 10 or later

  • Since the project is not compatible with Drupal 10 or later you need to add as repository
    # your composer.json file
      "repositories": [
            {
                "type": "vcs",
                "url": "https://git.drupalcode.org/project/certificatelogin"
            },
            {
                "type": "composer",
                "url": "https://packages.drupal.org/8",
                "only": [
                    "drupal/*"
                ]
            }
        ],
    

    and apply the patch 📌 Drupal 11 compatibility fixes for certificatelogin Active .

  • Add the module using composer require 'drupal/certificatelogin:2.x-dev@dev'.
  • Install the module as usual.
  • Login into Drupal with an administrator account
  • Visit the module configuration page /admin/config/people/certificatelogin

Proposed resolution

Since Drupal 10 ConfigFormBase requires the TypedConfigManager service to be passed as constructor argument. Just modify the CertificateLoginSettingsForm::create and CertificateLoginSettingsForm::__construct methods to inject the TypedConfigManager service (mind the type must be interface TypedConfigManagerInterface not the implementation) and pass it to the parent's constructor.

Remaining tasks

  • Fork issue
  • Provide a patch
  • Add some tests

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇪🇸Spain d70rr3s

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024