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:

  1. Install Drupal Commerce 2.x
  2. Create a text field on a variation type which links to its parent entity in a view mode.
  3. Create a view which renders variations in the view mode that was just configured.
  4. 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

bmcclure created an issue. See original summary.

replicaobscura’s picture

Issue summary: View changes

Version: 8.2.6 » 8.2.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.2.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

berdir’s picture

Status: Active » Closed (outdated)

Looks like this was fixed at some point? \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::getEntityUrl() checks if the entity has a revision link template.