Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::viewElements includes the code $url = $items->getEntity()->urlInfo('revision');. This seems to be making the assumption that the entity is revisionable (and thus has a "revision" link template) without checking. On non-revisionable entities, does this make sense?
It currently causes issues with Drupal Commerce in the following scenario:
- Install Drupal Commerce 2.x
- Create a text field on a variation type which links to its parent entity in a view mode.
- Create a view which renders variations in the view mode that was just configured.
- Try to display one or more product variations in that view.
It seems like anytime StringFormatter acts on a non-revisionable entity, this could possibly occur, though the bug will only present itself if there is also no "canonical" link template, such as in the case of Commerce where "canonical" is defined dynamically.
I proposed a patch for Commerce here: https://www.drupal.org/node/2847234
However, I'm not sure it makes sense for Commerce to have to check for the "revision" link template on an entity type which shouldn't require that link template to exist at all, which is why I'm opening this issue to see.
Comments
Comment #2
replicaobscuraComment #5
berdirLooks like this was fixed at some point? \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::getEntityUrl() checks if the entity has a revision link template.
Comment #6
dpiFixed in #3013029: StringFormatter should check whether an entity type has a 'revision' link template