Fix null given for not existing files.

Created on 13 December 2022, over 1 year ago
Updated 8 August 2023, 11 months ago

Problem/Motivation

When We try add not existing file from url file-dereference then we got an error like:
TypeError: Drupal\file_url\FileUrlHandler::isRemote(): Argument #1 ($file) must be of type Drupal\file\FileInterface, null given, called in /var/www/html/web/modules/contrib/file_url/src/Plugin/Field/FieldWidget/FileUrlWidget.php on line 223 in Drupal\file_url\FileUrlHandler::isRemote() (line 72 of /var/www/html/web/modules/contrib/file_url/src/FileUrlHandler.php)

Steps to reproduce

Add sample url like matches to pattern /\/file-dereference\/([0-9]+)/ link to not existing file.

Proposed resolution

Inside FileUrlHandler.php if not empty matches check if File is instance of FileInterface.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡΅πŸ‡±Poland crafter

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024