Skip to content

Fatal Error in 3.5.1 with PHP 8.3: ImageUrlConstraint::$message type mismatch #3188

@cyprus-karma

Description

@cyprus-karma

Describe the bug:
A critical fatal error occurs when running Google for WooCommerce v3.5.1 on PHP 8.3.25. The issue is caused by a type mismatch in the ImageUrlConstraint class. The $message property overrides the parent property from the Symfony Validator component but lacks the required string type declaration, which causes a fatal error in strict PHP 8.3 environments.

Steps to reproduce:
Set up a WordPress environment with PHP 8.3.25.
Install and activate Google for WooCommerce version 3.5.1.
Wait for the background synchronization process to run or trigger a product validation action.
Check the debug.log or server error logs.

Expected behavior:
The plugin should validate product image URLs without causing a fatal error.

Actual behavior:
The application crashes with a fatal error, preventing synchronization and filling the logs with critical errors.

Additional details:
Error Log:

text
CRITICAL Type of Automattic\WooCommerce\GoogleListingsAndAds\Validator\ImageUrlConstraint::$message must be string (as in class Symfony\Component\Validator\Constraints\Url)
CONTEXT: {"error":{"type":64,"file":"/wp-content/plugins/google-listings-and-ads/src/Validator/ImageUrlConstraint.php","line":15}}
System Info:

Plugin Version: 3.5.1
PHP Version: 8.3.25

Likely Cause: In PHP 8.3 (and newer Symfony versions), overridden properties must match the type definition of the parent class. The parent Symfony\Component\Validator\Constraints\Url defines public string $message, while ImageUrlConstraint likely defines it dynamically or without a type hint.

Regards. Boris

Metadata

Metadata

Labels

needs feedbackThe issue/PR needs a response from any of the parties involved in the issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions