Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Steps to reproduce:
- Enable workbench_moderation on node
- Create a rest view showing nodes
- Click on preview
- Look in the logs: you have route not found exception entries in there
Problem: \Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer
does NOT check whether a canonical route exists
Proposed resolution
Maybe its better fixed in core ...
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#2 | workbench_moderation-2682601-2.patch | 748 bytes | timmillwood |
Comments
Comment #2
timmillwood\Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer
does check to see if there is a canonical.So the error would only happen if an entity defines a canonical, but doesn't actually have one.
For example:
ModerationStateTransition
http://cgit.drupalcode.org/workbench_moderation/tree/src/Entity/Moderati...
It has a canonical in the links section of the annotation, but there is no
route_provider
for it, or canonical in workbench_moderation.routing.yml, therefore the normalizer will try to get the canonical, but a route doesn't exist for it.Here's a quick patch for that, but could do with more info on which routes are not found for @dawehner.
Comment #3
timmillwoodComment #4
dawehnerWell, at the same time we need them in order to have some form of REST support, right?
Comment #5
Crell CreditAttribution: Crell at Palantir.net for Acquia commentedMost entities don't have a canonical link right now, particularly config. The situation is kinda AFU, where some things want a canonical to work, but canonical isn't required and many/most entities don't have one. For content entities it's reasonably trivial to add one, but config entities have no default view handler to rely on. So, sucky. :-(
For the time being at least, "doesn't work with REST" is better than "Fatals", so let's commit this.
Comment #7
josephdpurcell CreditAttribution: josephdpurcell at Palantir.net for Acquia commentedMakes sense, we applied the same solution as this patch elsewhere.
Fixed!