Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 303489

Type of Drupal\\Core\\Extension\\Plugin\\Validation\\Constraint\\ExtensionNameConstraint::$message must not be defined (as in class Symfony\\Component\\Validator\\Constraints\\Regex)

$
0
0

Problem/Motivation

After updating Drupal core to 11.2.0, the following PHP fatal error occurs randomly:

PHP Fatal error: Type of Drupal\Core\Extension\Plugin\Validation\Constraint\ExtensionNameConstraint::$message must not be defined (as in class Symfony\Component\Validator\Constraints\Regex) in /var/www/html/gami-new/web/core/lib/Drupal/Core/Extension/Plugin/Validation/Constraint/ExtensionNameConstraint.php on line 19
This is caused by an incorrect property type declaration in the ExtensionNameConstraint class that conflicts with the parent class Symfony\Component\Validator\Constraints\Regex. The property $message in the parent class is untyped, but in the current file it is defined as public string $message, which is not allowed in PHP 8.3+.

Steps to reproduce

Update Drupal core to 11.2.0.

Run database updates.

Clear caches using Drush (drush cr).

Open the website.

Observe the fatal error in logs or browser.

Proposed resolution

Update the ExtensionNameConstraint class to remove the typed declaration from the $message property.

Incorrect:

public string $message = 'This value is not a valid extension name.';

Correct:

public $message = 'This value is not a valid extension name.';

This will bring the property in line with the parent class and ensure compatibility with PHP 8.3+.

Remaining tasks

Apply the fix.

Confirm the property type is removed.

Test on PHP 8.3.

Confirm no fatal errors occur.

Write/verify automated test coverage if applicable.

Merge the fix into the core codebase.


Viewing all articles
Browse latest Browse all 303489

Trending Articles