Add error handling/logging for missing files

Created on 25 April 2025, 4 days ago

Problem/Motivation

When the hash is being generated for a file that doesn't exist. It triggers a PHP warning along the lines of:

[warning] hash_file(public://deleted-file.pdf): Failed to open stream: "Drupal\Core\StreamWrapper\PublicStream::stream_open" call failed File.php:43

There should be a cleaner/dedicated logger for this scenario so that it can be better managed e.g. with monolog or filter for it within the watchdog logs.

Steps to reproduce

Delete the real file on disk, and attempt to regenerate the hash for the Media entity.

Proposed resolution

Check if the file exists before attempting to generate a hash for it.

Remaining tasks

Provide issue fork/patch.

User interface changes

N/A

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024