Problem/Motivation

EntityReferenceItem is missing dependency to the module that provides the target entity type.

  1. Steps to reproduce
  2. Install standard profile
  3. Uninstall Taxonomy
  4. Go to Article field settings and click Edit for the Tags field
  5. See error:
    PluginNotFoundException: The "taxonomy_term" entity type does not exist. in Drupal\Core\Entity\EntityManager->getDefinition() (line 259 of core/lib/Drupal/Core/Entity/EntityManager.php).
    Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::schema(Object)

Proposed resolution

In EntityReferenceItem::calculateDependencies(), find and include the provider of the target entity type.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Arla’s picture

Status: Active » Needs review
FileSize
2.05 KB

Bug trigger.

Status: Needs review » Needs work

The last submitted patch, 1: er_target_dependency-2479991-1-TESTS_ONLY.patch, failed testing.

Arla’s picture

Attempted to fix. I realised that FieldStorageConfig is not even asking the field type for dependencies. This patch is how far I got for now. It produces an error because it passes the field storage, not the field, as parameter to the field type calculateDependencies.

Status: Needs review » Needs work

The last submitted patch, 3: er_target_dependency-2479991-3.patch, failed testing.

The last submitted patch, 3: er_target_dependency-2479991-3-TEST_ONLY.patch, failed testing.

alexpott’s picture

Arla’s picture

So I guess it would be easy to make the field (instance) depend on the target type. Will look at that. But anyway the field storage should still depend on it as well.

Artusamak’s picture

FileSize
41.01 KB

The problem indicated in the issue with the steps to reproduce is now working with HEAD.
When you uninstall the taxonomy module the entity reference field using it is also removed (field_tags). See below:

Uninstall module screen

Then when you go in the content type configuration, everything is fine.

It looks like it's fixed to me.

catch’s picture

Status: Needs work » Closed (cannot reproduce)
Berdir’s picture

Status: Closed (cannot reproduce) » Closed (duplicate)

Doesn't look like this actually works now, otherwise #2520526: Calculate configuration entity dependencies on install wouldn't have to fix this problem :)

Keeping as closed but changing status to closed duplicate.

jackbravo’s picture