Problem/Motivation
On Drupal core 10.2+, ConfigFormBase::__construct() requires two arguments: ConfigFactoryInterface $config_factory and TypedConfigManagerInterface $typed_config_manager (see #3352994).
HighContrastConfigurationForm only injects ConfigFactoryInterface and calls parent::__construct($config_factory) with a single argument. On affected core versions this throws:
ArgumentCountError: Too few arguments to function
Drupal\Core\Form\ConfigFormBase::__construct(), 1 passed in
.../high_contrast/src/Form/HighContrastConfigurationForm.php on line 45
and exactly 2 expected in Drupal\Core\Form\ConfigFormBase->__construct()
This breaks the High Contrast settings form itself, and also breaks any code that programmatically invokes this form class (e.g. via FormBuilderInterface::submitForm()), since the container tries to instantiate it via ::create().
Steps to reproduce
Run Drupal core ≥ 10.2 with High Contrast installed.
Visit /admin/config/user-interface/high-contrast, or programmatically call \Drupal::formBuilder()->submitForm(HighContrastConfigurationForm::class, ...).
Observe the ArgumentCountError.
Proposed resolution
Inject TypedConfigManagerInterface in the constructor and create(), and forward it to parent::__construct(), matching the signature ConfigFormBase has required since core 10.2. Patch attached.
Remaining tasks
Needs review/testing on a couple of supported core versions to confirm no regression for sites still on core < 10.2 (where the second parameter was optional, so this stays backward compatible).
| Comment | File | Size | Author |
|---|---|---|---|
| high_contrast-fix-argument-count-error-configformbase.patch | 1.9 KB | zubair-rana |
Comments