Call to undefined method Drupal\media\Entity\Media::getFileURI()

Created on 14 August 2023, over 1 year ago
Updated 27 October 2023, about 1 year ago

Problem/Motivation

This error pops up when you visit the download-view/view page.

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\media\Entity\Media::getFileUri() in Drupal\vfd\Controller\DownloadViewController->download() (line 120 of modules/contrib/vfd/src/Controller/DownloadViewController.php).

Steps to reproduce

Caused by referencing file content using a media field type. In the code, it only checks if the the field type is either media or file, but if you try to download files that are referenced by medias, it'll throw this error.

Proposed resolution

Ad a statement within DownloadViewController.php after line 101 that will check if $node is a file entity and add a statement that will include it.

Remaining tasks

Received a warning error that mkdir($dir) in Downloadviewcontroller.php already exits. Maybe add an if state to check if the file already exists and what to do if it does

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇺🇸United States Tamerap

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

Comments & Activities

Production build 0.71.5 2024