Problem/Motivation
After installing the module and navigating to /admin/config/people/pcp, the site throws a fatal error instead of displaying the configuration form:
ArgumentCountError: Too few arguments to function Drupal\Core\Form\ConfigFormBase::__construct(), 1 passed in /var/www/html/xxxxxxx/web/modules/contrib/pcp/src/Form/PCPForm.php on line 33 and exactly 2 expected in Drupal\Core\Form\ConfigFormBase->__construct() (line 45 of /var/www/html/xxxxxxx/web/core/lib/Drupal/Core/Form/ConfigFormBase.php).
Steps to reproduce
- Install the pcp module on a Drupal 11.4.
- Navigate to
/admin/config/people/pcp. - Observe the fatal error above instead of the settings form.
Proposed resolution
In PCPForm.php:
1. Add the import:
use Drupal\Core\Config\TypedConfigManagerInterface;
2. Update the constructor to accept and forward the typed config manager:
public function __construct(
ConfigFactoryInterface $config_factory,
TypedConfigManagerInterface $typed_config_manager
) {
parent::__construct($config_factory, $typed_config_manager);
}
3. Update create() to inject the new service:
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed')
);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3608602_patch_against_2_0_0.patch | 1.51 KB | aurelianzaha |
Issue fork pcp-3608602
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
garvitasakhrani commentedUpdated PCPForm to inject the typed config manager required by Drupal 11, resolving the ConfigFormBase::__construct() ArgumentCountError.
Please review. Thanks!
Comment #5
dkmishra commentedI reviewed the merge request and tested it locally. The changes apply cleanly, and I can confirm that they resolve the reported issue. I didn't encounter any regressions during testing.
Comment #6
aurelianzaha commentedI created a static patch against the latest release (2.0.0) in case someone else needs it, you can find it attached
Comment #7
vinodhini.e commentedHi,
Tested this on Drupal 11.4.2 and encountered the same issue while accessing the configuration page. Applied MR #13 and retested; the configuration page now loads properly without any errors.
+1 RTBC
Thanks.
Comment #10
abrammThat's clearly a bug. Thank you everyone for reporting and reproducing it!
I don't like the constructor approach, though; technically, it may break again in some future core version. Also, while adding additional parameters to the parent constructor call is technically valid in older core versions, that could be confusing.
I'm going to check if it's possible to remove the constructor override at all and assign the new property in create().
Comment #12
abrammFixed, the 2.0.1 release should be created in a few minutes. Thank you everyone!