Problem/Motivation

When I try to access the dashboard URL I get
ArgumentCountError: Too few arguments to function Drupal\url_status_scanner\Form\UrlStatusScannerDashboard::__construct(), 0 passed in /var/www/drupal/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php on line 44 and exactly 3 expected in Drupal\url_status_scanner\Form\UrlStatusScannerDashboard->__construct() (line 50 of modules/contrib/url_status_scanner/src/Form/UrlStatusScannerDashboard.php).

Steps to reproduce

I am using Drupal 10.6.2 with php 8.3 and I installed the module using composer.json and drush and then I go to the URL /admin/url-status-scanner/dashboard and it gives the above error.

Proposed resolution

This commit 5c194218 made it so the Class no longer extended FormBase but if you change it back to extend FormBase the dashboard works. Not sure what the motivation behind removing that dependency were but w/o it the module is broken.

Remaining tasks

User interface changes

API changes

Data model changes

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

robbt created an issue. See original summary.

robbt’s picture

Priority: Normal » Major
Issue summary: View changes
robbt’s picture

I saw this change was made because of the advice that it didn't need to extend the FormBase here - https://www.drupal.org/project/projectapplications/issues/3515103 but I suspect that even if this was the case you need to put 'implements FormInterface' otherwise you get the error. I haven't tried this yet but I will see if this fixes it.

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

nickolaj’s picture

Status: Active » Needs review

Restored `extends FormBase` to the dashboard form class. The class was changed to a plain class but still uses dependency injection via `create()` and inherited methods like `$this->t()`, `$this->messenger()`, and `$this->getRequest()` which require FormBase.

gustavo.contreras’s picture

Assigned: Unassigned » gustavo.contreras
Status: Needs review » Fixed

Root cause:
The dashboard form class was changed to a plain class and no longer
extended FormBase. However, the class still relies on dependency
injection and methods provided by FormBase such as $this->t(),
$this->messenger(), and $this->getRequest().

Because of this, Drupal instantiated the class without container
injection, which resulted in an ArgumentCountError due to the
constructor expecting three arguments.

Resolution:
Restored `extends FormBase` to ensure proper container-based
instantiation and restore compatibility with Drupal 10.

Tested on Drupal 10.6.x with PHP 8.3.

Thanks to @robbt for reporting the issue and for the initial analysis,
and to @nickolaj for opening the merge request and helping move this forward.

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.