Fatal error when deleting media type

Created on 20 April 2023, about 1 year ago
Updated 4 May 2023, about 1 year ago

Problem/Motivation

When using group 3.0.x and groupmedia 4.0.x I get a 500 error when deleting a media type.

I am not sure if this issue is for group or groupmedia - I am adding here as I was not sure if I should expect to see the plugin causing this error, although I do suspect this could be more of an issue for group module.

Drupal\Core\Entity\EntityStorageException: Trying to wrap an unsupported entity of type "media_type". in Drupal\group\Entity\Storage\ConfigWrapperStorage->wrapEntityId() (line 40 of modules/contrib/group/src/Entity/Storage/ConfigWrapperStorage.php). 

Steps to reproduce

Enable groups module (3.0.x)
Enable groupmedia (4.0.x)
Add a media type (at /admin/structure/media/add)
Delete that media type
Drupal returns a 500 error

Proposed resolution

I do not know if this is a group issue or a groupmedia issue - but it seems to stem from the group_media_type.

I do not see why I need this plugin enabled as it is not related to the media entity derived plugins - but if I either enable the group_media_type plugin for a group, or delete the plugin code, the issue does not show.

From my debugging what is happening is

  1. group_entity_delete files and calls $storage->loadByEntity($entity) in GroupRelationShipStorage
  2. GroupRelationShipStorage calls $this->pluginManager->getPluginIdsByEntityTypeId('media_type')
  3. group_media_type is returned from that call, so the method continues and calls $entity_id = $storage->wrapEntity($entity) on ConfigWrapperStorage
  4. ConfigWrapperStorage calls wrapEntityId, which fails a check at supportsEntityTypeId('media_type')and throws the Exception

When the plugin is enabled supportsEntityTypeId is returning true and so the issue is not present - although I see no need to have this plugin enabled if I don't want config entities owned by groups. This makes me thing it is potentially a groups issue?

Remaining tasks

I am not familiar with the new groups module APIs - so I am not clear on this one. I think either Group should be catching the exception - or
group_media_type - is this plugin complete? I don't see any reference to it in tests or documentation. I can't recall if having groups own media type bundles was thing before (this is different to media entities of a given type - this plugin is for the actual media type config entity).

User interface changes

?

API changes

?

Data model changes

?

πŸ› Bug report
Status

Closed: outdated

Version

4.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand ericgsmith

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

Comments & Activities

Production build 0.69.0 2024