Unlink warnings after removing media from field

Created on 20 March 2025, 24 days ago

I get the following unlink warning multiple times after I remove a focal-pointed/cropped media image from a field and save the node:

Warning: unlink(): No such file or directory in Drupal\Core\File\FileSystem->unlink() (line 118 of core/lib/Drupal/Core/File/FileSystem.php).
Drupal\Core\File\FileSystem->unlink() (Line: 304)
Drupal\Core\StreamWrapper\LocalStream->unlink()
unlink() (Line: 118)
Drupal\Core\File\FileSystem->unlink() (Line: 332)
Drupal\media_contextual_crop\MediaContextualCropService->deleteDerivative() (Line: 81)
media_contextual_crop_crop_delete()

The warning happens multiple times, which is likely due to an attempt to delete every image derivative.

It appears that MediaContextualCropService::createContextualizedDerivativePath() already deletes the derivatives. So when that method is called from deleteDerivatives(), the service is now trying to delete files it just deleted.

Steps:

1. I have a content type with a "Media with contextual modifications" field that references an Image media entity;
2. And I create a node and add an image, such as a JPG, and set a focal point on the image, and save the node;
3. And I edit the node again and remove the media from the field, and then save the node.

πŸ› Bug report
Status

Active

Version

2.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States aasarava San Diego

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