Problem/Motivation
I had this issue https://www.drupal.org/project/workflow/issues/3415585.
A view containing a contrib workflow (https://www.drupal.org/project/workflow) "From state"/"To state" item worked in Drupal 10.1.x but broke in Drupal 10.2.x because of changed behaviour in views. Somehow those two elements had the option "Link label to the referenced entity" switched on, which should invoke the canonical view of them, but the elements never had a canonical view to start with. In Drupal 10.1.x this gets ignored, in Drupal 10.2.x it actually breaks the view.
Solution was to switch the option off to make it work. But more people will probably hit the problem, and it would be the nice if the option "Link label to the referenced entity" is not shown when the element in question does not have a canonical view (which should also automatically switch the option to off).
Steps to reproduce
Proposed resolution
#4. We could at least silently catch the exception in Views to avoid breaking things entirely.
Comments
Comment #2
larowlanI think the change to default arguments to ::toUrl may have been the issue
It broke aggregator module too
Comment #3
sboden commentedThe problem is with a change in functionality of calling a canonical view when the "Link label to the referenced entity" is switched on. In Drupal 10.1.x when an element does not have a canonical view Drupal "skips" requesting it, while in Drupal 10.2.x you get a WSOD when the canonical view/route is called.
For this I would propose not to show the "Link label to the referenced entity" for an element that does not have a canonical view. This would avoid Drupal calling something which does not exist. Example for this are the "From state"/"To state" fields from the contrib workflow module.
Comment #4
longwaveWe could at least silently catch the exception in Views to avoid breaking things entirely.
Is there a core module that can be used to write a test for this?
Comment #5
lendudeThis checkbox comes from \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceLabelFormatter, Views just reuses the field formatter, so not sure if this is something Views should be handling or the FieldFormatter itself.
@larowlan is #3371753: Fall back to 'edit-form' as default $rel in EntityBase::toUrl() the change you are referring to? The formatter seems to catch the new exception thrown there so not sure.
Comment #6
larowlanYeah that's the one that broke aggregator
Comment #7
quietone commentedComment #9
longwaveJust run into this with search_api_saved_searches and the SavedSearchType entity. Changing to a bug report, because this broke a view that worked in 10.1 but not in 10.2.
The problem is that the entity declares the canonical and edit-form templates to be the same:
then this code makes an assumption about the route name:
However the
entity.search_api_saved_search_type.canonicalroute does not actually exist - it shouldn't need to because theentity.search_api_saved_search_type.edit_formroute does exist.Perhaps the whole block in EntityBase::toUrl() needs reworking to ensure that the route that it selects does actually exist; if the canonical route doesn't exist it could fall back to the edit-form route instead?
Also wondering if the real underlying problem here is the entire concept of link templates; we use routes everywhere else for generating URLs, so shouldn't link templates actually be route templates?
Comment #10
larowlanRelated too #3427515: Route "entity.workbench_email_template.canonical" does not exist