The FieldConfig entity should have a dependency on the module that provides the entity type. So if you create a field on taxonomy terms then it will depend on the taxonomy module since the field has no meaning with the taxonomy module.

Files: 
CommentFileSizeAuthor
#4 2232597.4.patch8.03 KBalexpott
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,648 pass(es). View
#4 1-4-interdiff.txt3.3 KBalexpott
#1 2232597.1.patch7.33 KBalexpott
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,510 pass(es). View

Comments

alexpott’s picture

Status: Active » Needs review
FileSize
7.33 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,510 pass(es). View

A patch to what is outlined in the summary.

alexpott’s picture

Berdir’s picture

+++ b/core/modules/field/tests/Drupal/field/Tests/FieldConfigEntityUnitTest.php
@@ -88,10 +84,34 @@ public function setUp() {
+    // Get definition is called three times. Twice in
+    // ConfigEntityBase::addDependency() to get the provider of the field config
+    // entity type and once in FieldConfig::calculateDependencies() to get the
+    // provider of the entity type that field is attached to.
+    $this->entityManager->expects($this->at(0))
+      ->method('getDefinition')
+      ->with($this->entityTypeId)
+      ->will($this->returnValue($fieldConfigentityType));
+    $this->entityManager->expects($this->at(1))
+      ->method('getDefinition')
+      ->with($this->entityTypeId)
+      ->will($this->returnValue($this->entityType));
+    $this->entityManager->expects($this->at(2))
+      ->method('getDefinition')
+      ->with($this->entityTypeId)
+      ->will($this->returnValue($fieldConfigentityType));

This is super-confusing. Can't we use two different entity type ID's if we need two different types? This doesn't seem like a realistic scenario, we could be calling it with the wrong ID or something?

alexpott’s picture

FileSize
3.3 KB
8.03 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,648 pass(es). View

Good point.

xjm’s picture

Issue tags: +Configuration system
Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Yes, now the test makes much more sense :)

I guess it would also be possible to solve getDefinition() with a $this->returnValueMap(), but the explicit expectations and explanation of calls is in this case is OK I think. (It sometimes is too strict and makes internal refactoring painful...)

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit 94bdf61 on 8.x by catch:
    Issue #2232597 by alexpott: FieldConfig does not depend on the module...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.