SmartmenusSettingsForm fatal error: ArgumentCountError, ConfigFormBase requires TypedConfigManagerInterface
Problem/Motivation
Visiting /admin/config/user-interface/smartmenus throws a fatal error:
ArgumentCountError: Too few arguments to function Drupal\Core\Form\ConfigFormBase::__construct(), 1 passed in .../smartmenus/src/Form/SmartmenusSettingsForm.php on line 27 and exactly 2 expected in Drupal\Core\Form\ConfigFormBase->__construct() (line 46 of core/lib/Drupal/Core/Form/ConfigFormBase.php).
Drupal core's ConfigFormBase::__construct() was changed to require a second constructor argument, \Drupal\Core\Config\TypedConfigManagerInterface $typedConfigManager:
public function __construct( ConfigFactoryInterface $config_factory, protected TypedConfigManagerInterface $typedConfigManager, ) { this->setConfigFactory(config_factory); }
SmartmenusSettingsForm::__construct() only calls parent::__construct($config_factory) with one argument, so any attempt to load the settings form throws ArgumentCountError and the page is unusable.
Steps to reproduce
- Install smartmenus on a Drupal core version where ConfigFormBase requires two constructor arguments.
- Visit /admin/config/user-interface/smartmenus.
- Observe the fatal error above instead of the settings form.
Proposed resolution
Update SmartmenusSettingsForm to accept and forward a TypedConfigManagerInterface service, matching the current ConfigFormBase signature:
- Add use Drupal\Core\Config\TypedConfigManagerInterface;
- Add TypedConfigManagerInterface typed_config_manager as the second constructor parameter and pass it to parent::__construct(config_factory, $typed_config_manager)
- Inject the config.typed service in create()
Patch attached: configformbase-typedconfigmanager.patch configformbase-typedconfigmanager.patch