Spin off from #2913523: Order item referencing addon entity breaks order item Views integration. Minor as its an edge case.
OrderItemViewsData builds a relationship dynamically from the order item to the purchasable entity type based on the order item type's purchasable entity.
// Provide a relationship for each entity type found.
foreach ($entity_type_ids as $entity_type_id) {
/** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
$entity_type = $this->entityManager->getDefinition($entity_type_id);
This line of code breaks, however, if that entity has disappeared and Drupal didn't remove the order item type configuration.
We need to add a `hasDefinition` check before assuming the definition exists.
Comments
Comment #2
iuana commentedI added the verification of hasDefinition on the entity type id.
Comment #3
iuana commentedComment #4
bojanz commentedIt impacts readability to indent the whole large block of code for what is an IF check for an edge case.
Instead, let's perform the IF check, and then continue; if the definition is missing. Basically having it function as a guard clause:
Comment #5
iuana commentedYes, indeed. I reupload the patch. Thanks for reviewing it.
Comment #6
iuana commentedComment #7
iuana commentedsorry for the name of the patch.
Comment #8
bojanz commentedThanks!