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

  1. Install the pcp module on a Drupal 11.4.
  2. Navigate to /admin/config/people/pcp.
  3. 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')
  );
}
CommentFileSizeAuthor
#6 3608602_patch_against_2_0_0.patch1.51 KBaurelianzaha

Issue fork pcp-3608602

Command icon 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

dkmishra created an issue. See original summary.

garvitasakhrani made their first commit to this issue’s fork.

garvitasakhrani’s picture

Status: Active » Needs review

Updated PCPForm to inject the typed config manager required by Drupal 11, resolving the ConfigFormBase::__construct() ArgumentCountError.
Please review. Thanks!

dkmishra’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

aurelianzaha’s picture

StatusFileSize
new1.51 KB

I created a static patch against the latest release (2.0.0) in case someone else needs it, you can find it attached

vinodhini.e’s picture

Hi,

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.

abramm made their first commit to this issue’s fork.

abramm’s picture

Assigned: Unassigned » abramm
Status: Reviewed & tested by the community » Active

That'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().

  • abramm authored dc574b52 on 2.0.x
    fix: #3608602 ArgumentCountError: Too few arguments to ConfigFormBase::...
abramm’s picture

Assigned: abramm » Unassigned
Status: Active » Fixed

Fixed, the 2.0.1 release should be created in a few minutes. Thank you everyone!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.