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.
Comments
Comment #3
keszthelyi commentedPatch from 3c71bdcd
Comment #4
keszthelyi commentedComment #5
keszthelyi commentedPatch from 77844c29
Comment #6
keszthelyi commentedRemoved the string check from #3 as we can be sure it's a string if not NULL.
Comment #7
dxvargas commentedIt makes sense to not validate an empty source field.
I've tested with Drupal core 10, 1.x-dev and using a multiple taxonomy term reference field. Before when adding a new item I had this error. After applying the patch the error was gone.
Comment #9
hernani commentedMerged into 2.x