PHP error on AJAX calls when validating resource URLs

Created on 5 October 2023, 9 months ago
Updated 9 October 2023, 9 months ago

Problem/Motivation

Our AV Portal media types have field widgets that are using AJAX. On the media edit form, when the source field is not yet filled in by the user, the widget AJAX calls produce this error:

TypeError: Drupal\media_avportal\AvPortalClient::getResource(): Argument #1 ($ref) must be of type string, null given, called in /src/Plugin/Validation/Constraint/AvPortalResourceConstraintValidator.php on line 59 in Drupal\media_avportal\AvPortalClient->getResource() (line 121 of /src/AvPortalClient.php).

Proposed resolution

The validator should make sure that the value passed to AvPortalClient::getResource() is a string and it should not validate the URL if the source field is empty.

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium keszthelyi Brussels

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

Comments & Activities

Production build 0.69.0 2024