Problem
The normalization of content entities with a translation fails as the default_langcode property is not handled correctly. This might not be problematic for REST, but is a show stopper for contributed modules which want to use the entity serialization API.
At least, default content module fails with entity translations due to this: #2680135: Support for entities with translations is broken.
Proposed resolution
Fix the core normalizers to handle translations correctly.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#11 | d8_entity_translation_serialization.patch | 4.99 KB | fago |
#10 | d8_entity_translation_serialization.interdiff.txt | 834 bytes | fago |
#2 | d8_entity_translation_serialization.patch | 5.21 KB | fago |
Comments
Comment #2
fagoHere is patch which fixes the problem for the content entity normalizer of hal module.
Note that the content entity normalizer of serialization will have the same problem as it does not deal with languages at all, but I think the root problem here is the total separation of \Drupal\hal\Normalizer\ContentEntityNormalizer from \Drupal\serialization\Normalizer\ContentEntityNormalizer. The HAL variant should probably extend the serialization one and restrict itself to its own format as I suggested in #2792169: HAL normalizers simply replace the default normalizers. But that re-factoring would be better handled in a separate issue imo.
Comment #3
fagoComment #4
fagoCorrecting things a bit: What's actually broken is de-normalizing, normalizing works fine.
Comment #5
jibranWe have a fix and passing tests. The code looks good and it also fixed #2680135: Support for entities with translations is broken.
Comment #6
larowlanNice work, this should go into 8.1.x thought as its a bug (and then forward port)
Comment #7
alexpottJust confirming the test fails without the patch.
Comment #8
catchIs the router rebuild really necessary for the test to pass? Link generation or something?
Comment #9
xjmNR for #8.
Comment #10
fagoIndeed, the router rebuild is not necessary.
Comment #11
fagoComment #12
jibranThanks @fago back to RTBC.
Comment #13
fagoMoving to 8.3.x.
Comment #14
alexpottCommitted feb3a4d and pushed to 8.3.x. Thanks!
Setting to patch to be ported for cherry-pick to 8.2.x once 8.2.0 is out.
Comment #16
alexpottCommitted 984f899 and pushed to 8.2.x. Thanks!