problems with backward compatible code in FileMatcher::buildDescription()

Created on 16 January 2025, 4 days ago

Problem/motivation

Initially, trying to use a file matcher, I was seeing this error:

ArgumentCountError: Too few arguments to function Drupal\linkit\Plugin\Linkit\Matcher\FileMatcher::Drupal\linkit\Plugin\Linkit\Matcher\{closure}(), 0 passed in /home/www/drupal9/web/core/lib/Drupal/Component/Utility/DeprecationHelper.php on line 40 and exactly 3 expected in Drupal\linkit\Plugin\Linkit\Matcher\FileMatcher::Drupal\linkit\Plugin\Linkit\Matcher\{closure}() (line 205 of /home/www/drupal9/web/modules/contrib/linkit/src/Plugin/Linkit/Matcher/FileMatcher.php).

From my reading of the documentation and examples for using DeprecationHelper::backwardsCompatibleCall(), I rewrote the functions slightly. That fixed the initial problem but then revealed subsequent issues with the function calls and invalid arguments:

TypeError: Drupal\file\Validation\FileValidator::validate(): Argument #1 ($file) must be of type Drupal\file\FileInterface, string given, called in /home/www/drupal9/web/modules/contrib/linkit/src/Plugin/Linkit/Matcher/FileMatcher.php on line 206 in Drupal\file\Validation\FileValidator->validate() (line 43 of /home/www/drupal9/web/core/modules/file/src/Validation/FileValidator.php).

TypeError: Cannot assign array to property Drupal\file\Plugin\Validation\Constraint\FileExtensionConstraint::$extensions of type string in Symfony\Component\Validator\Constraint->__construct() (line 133 of /home/www/drupal9/vendor/symfony/validator/Constraint.php).

I verified this on a Drupal 11.1.1 installation using PHP 8.3.14 and Linkit 7.x-dev.

πŸ› Bug report
Status

Active

Version

7.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brad.bulger

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024