Deprecated function: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated

Created on 12 August 2024, 5 months ago

Problem/Motivation

This issue arose for me when trying to save a media item with no values for a remote image. We get the following error:

Deprecated function: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in Drupal\media_entity_remote_image\Plugin\Validation\Constraint\RemoteImageUrlConstraintValidator->validate() (line 28 of modules/contrib/media_entity_remote_image/src/Plugin/Validation/Constraint/RemoteImageUrlConstraintValidator.php).

Steps to reproduce

Create a media item with a remote image field and try to save the media item. This error should be thrown as the php function pathinfo now requires a non-null value as argument #1

Proposed resolution

Patch attached

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States peachez

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

Merge Requests

Comments & Activities

  • Issue created by @peachez
  • πŸ‡ΊπŸ‡ΈUnited States peachez
  • Status changed to Needs review 5 months ago
  • πŸ‡ΉπŸ‡­Thailand Nick Hope

    The MR !9 (in #4) address the problem by simply making the URL field required.

    This should also address these issues:

    To me, this seems logical. I suppose someone might want to create a media entity as a placeholder, and add the URL later, but I doubt it.

    @peachez Was it just an empty URL field that caused the problem? And why were you saving a media item without that value?

    If anyone was able to get past the issue and actually create media remote image entities with empty URL fields, we could consider a hook_update_N() to populate empty URL fields with a placeholder value etc.. Does anyone have media remote image entities with empty URL fields?

    Also uploading a patch for anyone who wants it.

  • πŸ‡ΊπŸ‡ΈUnited States peachez

    @nick

    Yes just the media file field caused us the issue.

    I believe we had a use case for media items where our client wanted to create the media items with some of the data (keeping it in draft) but had not been given the video file yet to upload.

    Thanks for the help

Production build 0.71.5 2024