Error when removing a media item that has focal point set

Created on 20 March 2025, 25 days ago

I'm seeing the following WSOD error when I set a focal point on a media item and then come back alter and remove that item from the field:
```
AssertionError: Cannot load the "media" entity with NULL ID. in assert() (line 261 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).
Drupal\Core\Entity\EntityStorageBase->load() (Line: 503)
Drupal\Core\Entity\EntityBase::load() (Line: 104)
media_contextual_crop_field_formatter_entity_update()
```

Reloading the page shows this related warning that is probably why the error above is happening:
```
Warning: Undefined array key 0 in media_contextual_crop_field_formatter_entity_update() (line 104 of modules/contrib/media_contextual_crop_field_formatter/media_contextual_crop_field_formatter.module)
```

Steps:

1. If I have a content type with a "Media with contextual modifications" field that references an Image media entity;
2. And if 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 if I edit the node again and remove the media from the field, and then save the node;

πŸ› Bug report
Status

Active

Version

2.0

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