Handle possible entity storage exception due to undefined variable $resource_url

Created on 22 November 2024, 5 months ago

Problem/Motivation

I am working on a project that has a Kernel test to test the output of the paragraphs by comparing it to the pre-defined fixtures. Some paragraphs have a media reference field pointing to one of the available media types - Image, Video, Remote Video, etc. The following error happens when we try to run with a few paragraph types:

Drupal\Core\Entity\EntityStorageException: Undefined variable $resource_url

/var/www/html/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:817
/var/www/html/docroot/core/lib/Drupal/Core/Entity/EntityBase.php:354

Steps to reproduce

  • Try to create a new entity of any type that might have an entity reference field pointing to a media type (preferably remote_video). Use Drupal\Core\Field\FieldItemListInterface::generateSampleItems to generate the media reference fields' value.
  • Call $entity->save();

Expected result: You should be able to create an entity, and the exception should be logged about metadata error.

Actual result: You get the error above.

Proposed resolution

Handle the possible undefined error.

Remaining tasks

MR.

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

TBD

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

media system

Created by

🇮🇳India ajits India

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

Comments & Activities

Production build 0.71.5 2024