Deprecated function: Creation of dynamic property Drupal\linkchecker\Form\LinkCheckerAdminSettingsForm::$moduleHandler is deprecated

Created on 19 March 2025, 18 days ago

Problem/Motivation

Link Checker reports deprecation error.
Deprecated function: Creation of dynamic property Drupal\linkchecker\Form\LinkCheckerAdminSettingsForm::$moduleHandler is deprecated in Drupal\linkchecker\Form\LinkCheckerAdminSettingsForm->__construct() (line 96 of modules/contrib/linkchecker/src/Form/LinkCheckerAdminSettingsForm.php).

Steps to reproduce

  • Install Link Checker
  • Visit Settings page (admin/config/content/linkchecker)

PHP: 8.3.16
Result:
Deprecation message appears at the top of the page and in dblog.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States alex9000

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @alex9000
  • 🇮🇳India arunsahijpal

    Working on it.

  • 🇮🇳India arunsahijpal

    Hi @alex9000,
    This warning is due to the dynamic property $moduleHandler being assigned directly in the constructor of LinkCheckerAdminSettingsForm.
    So we require a docblock comment in order to remove the warning.

    I see that that docblock is present in 2.0.x and 2.1.x but it is not present when you do composer require 'drupal/linkchecker:^2.0' so you can use these versions instead or you can explicitly write this docblock.

      /**
       * ModuleHandler service.
       *
       * @var \Drupal\Core\Extension\ModuleHandlerInterface
       */
      protected $moduleHandler;
    

    @vladimiraus please check this.

    Thanks,
    Arun

Production build 0.71.5 2024