- Issue created by @welly
- 🇮🇳India abhishek@kumar
Option A: Ensure Group Relationship Exists Before Deletion
foreach ($relatedEntities as $relatedEntity) { if ($relatedEntity->hasField('group_id') && !$relatedEntity->get('group_id')->isEmpty()) { $relatedEntity->delete(); } }
Option B: Implement hook_entity_predelete()
/** * Implements hook_entity_predelete(). */ function YOURMODULE_entity_predelete(EntityInterface $entity) { if ($entity->getEntityTypeId() === 'group_content_menu') { // Ensure the entity has a valid group relationship if (!$entity->hasField('group_id') || $entity->get('group_id')->isEmpty()) { // Temporarily add a dummy group relationship if needed $entity->set('group_id', 0); } } }
Option C: Patch Group Content Menu Module
The module should properly handle cases where group relationships are missing, either by:
- Preventing such entities from being created
- Providing proper fallback behavior during deletion
- 🇬🇧United Kingdom welly
Thanks for this, however I'm not sure that's quite right. The entity type doesn't have a group_id field because the relationship to the group is provided by the group relationship entity. It wouldn't be expected for the related entity to have a group_id field. I suspect ChatGPT is hallucinating in this instance ;-)