Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
EntityDisplayBase::getFieldDefinitions() checks that the $entity_type the Display applies to is Fieldable :
// Entity displays are sometimes created for non-content entities.
// @todo Prevent this in https://drupal.org/node/2095195.
if (!\Drupal::entityManager()->getDefinition($this->targetEntityType)->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
return array();
}
That same check is performed in the __construct() :
if (!$this->entityManager()->getDefinition($values['targetEntityType'])->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
throw new \InvalidArgumentException('EntityDisplay entities can only handle content entity types.');
}
- We could remove the check in getFieldDefinitions()
- Not sure why we check Fieldable. EntityDisplays should be about ContentEntities, but no reason to limit to those with fields.. OK, FieldableEntitiyInterface is larger than ContentEntityInterface. Then the exception message needs to be updated.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2409661_EntityDisplay_duplicate_check-5.patch | 1.5 KB | yched |
#1 | 2409661_EntityDisplay_duplicate_check-1.patch | 1.52 KB | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedPatch.
Comment #2
yched CreditAttribution: yched commentedBump - easy RTBC ?
Comment #3
BerdirYes, looks good to me. I wasn't sure if it will conflict with #2248795: Entity displays fetch the bundle field definitions for deleted bundles, possibly, but we can always re-roll after one issue is in.
Comment #5
yched CreditAttribution: yched commentedReroll
Comment #6
alexpottDuplicate code is a bug. This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed b524d3d and pushed to 8.0.x. Thanks!