- Merge request !184Resolve #3548053 "Entityautocompletetagify reference error" β (Merged) created by gxleano
When using the EntityAutocompleteTagify element, if there is an entity reference to a content entity that has been deleted, the following error occurs:
TypeError: Drupal\Core\Entity\EntityRepository::getTranslationFromContext():
Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface, null given,
called in /var/www/html/public_html/modules/contrib/tagify/src/Element/EntityAutocompleteTagify.php on line 247
in Drupal\Core\Entity\EntityRepository->getTranslationFromContext()
(/var/www/html/public_html/core/lib/Drupal/Core/Entity/EntityRepository.php line 94). 1. Create an entity reference field that uses the Tagify autocomplete widget.
2. Reference a content entity (e.g., a node).
3. Delete the referenced content entity.
4. Edit the referencing entity.
Actual result:
A fatal error is thrown because getTranslationFromContext() receives null instead of an EntityInterface.
Expected result:
The widget should handle missing/deleted entities gracefully (e.g., skip them or show a placeholder), without throwing a fatal error.
Active
1.2
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.