Problem/Motivation
Simply installing Content Translation on a site with rest resources breaks those resources. This is because Content Translation adds drupal:content-translation-overview links (and others) to entities, but it does not declare those relation types. Rest resource URLs throw an unhandled exception due to this.
Note that this was found (somewhat by accident) in #3367475: [meta] Improve support for entity types without a canonical link but also has come up in #2135829: EntityResource: translations support.
See also #3088282: Missing Views link relationships when Views UI installed for a similar issue where Views UI did not provide link relation types for links it was using.
Steps to reproduce
- Install Rest and Node and visit the shipped node resource for a given node.
- Install Content Translation.
- Reload the resource.
Proposed resolution
Provide the respective link relation types.
Remaining tasks
Subsystem maintainer review
User interface changes
-
API changes
-
Data model changes
Content Translation now provides the following link relation types:
- drupal:content-translation-overview
- drupal:content-translation-add
- drupal:content-translation-edit
- drupal:content-translation-delete
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3368071-3.patch | 5.39 KB | tstoeckler |
| #2 | 3368071-2.patch | 4.25 KB | tstoeckler |
Issue fork drupal-3368071
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3368071-content-translation--rest
changes, plain diff MR !8726
Comments
Comment #2
tstoecklerHere's a test only patch to prove the bug. I opted to simply installing Content Translation in the respective rest resource base classes instead of adding dedicated tests as there really is no translation-related functionality that we are testing here. It's simply about the fact that the resources work as before even with Content Translation enabled. But I guess this is arguable and could be changed, as well.
Didn't check why the language cache context is bubbled in the resources, but it doesn't seem problematic to me.
Comment #3
tstoecklerAnd here's the fix. Stole the comment in the YAML file from the Views UI implementation in case anyone is wondering.
Comment #5
senthilmohith commentedComment #6
smustgrave commented@SenthilMohith thank you for the interest but shouldn't assign tickets to yourself unless a maintainer per https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquett...
queuing for 11.x tests.
Comment #7
smustgrave commentedTests all green.
Also ran a test locally without the fix file and the testGet() failed with
Think this is good.
Comment #9
tstoecklerRandom failure, back to RTBC
Comment #10
longwaveWhy are these prefixed with
drupal:? No other Drupal-specific link relations have this prefix.Comment #11
smustgrave commentedTrue. Moving to NW to update links.
Comment #12
tstoecklerFirst of all, not sure that's true.
canonical,edit-form, etc. are all standard IANA link relation types. The idea was to use thedrupal:prefix for all custom ones. We may not have followed through on that correctly, not sure off the top of my head.But regardless, this is not establishing the content translation link relation types, they already exist and are being used. They are just missing their declaration. And Rest module happens to ve particularly strict about that.
So moving back to needs review as I'm not sure what else could be done here.
Comment #13
tstoecklerAny response @longwave or @smustgrave? Per the above I don't think the criticism of the patch was warranted. I also took another look at the issue summary and I think the situation is explained sufficiently there, as well. Not going to re-RTBC myself because people are very sensitive with that, but maybe either of you can confirm and do so? Would be much appreciated.
Comment #14
smustgrave commentedGoing to put in committer bucket to get more eyes on it.
Not sure I could make the call.
Comment #15
tstoecklerGreat, thanks!
Comment #16
quietone commentedI'm triaging RTBC issues. I read the IS and the comments.
Thanks for answering longwave's query. Due to the adding of the prefix, this should have subsystem maintainer review first (I checked with xjm)
Comment #17
longwaveOh I see:
So we already declare these link templates - this code has existed since 8.0. But we didn't define the metadata for them, which REST module requires. Changing these now would break backward compatibility with code that already uses them, which is out of scope of this issue.
Comment #18
tstoecklerRe #16: Again, this is not adding a prefix. It's just formally declaring, i.e. in a sense documenting, something that is already used. Subsystem maintainer review never hurts, so I have no issue with adding that tag, but wanted to point that out.
Re #17: Exactly. I tried to explain this in the issue summary, but maybe I didn't do a super good job. But that is exactly the point.
Comment #20
tstoecklerComment #21
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #23
tstoecklerYup, back to RTBC then. Just pushed the patch to an MR, so the RTBC from #14 still applies.
Comment #28
catchOK @tstoeckler's explanation means we don't need subsystem maintainer review, just a misunderstanding about the links already existing (which I also would have done probably).
Committed/pushed to 11.x and cherry-picked back through to 10.3.x, thanks!
Comment #31
xjmBelatedly crediting myself for release management review, and @quietone for asking the question.