The commit of #1818556: Convert nodes to the new Entity Field API broke Edit module's metadata callback. Note that there is test coverage. But the whole business of moving from EntityPG to EntityNG (#1346214: [meta] Unified Entity Field API) has caused some of the tests to test EntityPG instead of EntityNG, which was the case here. Hence this could go on undetected.
The fix is easy:
- $items = $entity->get($field_name);
- $items = $items[$langcode];
+ $items = $entity->getTranslation($langcode)->get($field_name)->getValue();
However, it's the tests that also require updating to EntityNG. For that, I copied a subset of #1822000-26: Remove Drupal\field_test\Plugin\Entity\Type\TestEntity in favor of EntityTest verbatim — it was Berdir who wrote the fixed tests and hence should be credited here.
Related
#1939994: Complete conversion of nodes to the new Entity Field API
Comment | File | Size | Author |
---|---|---|---|
#3 | edit_entity_ng-1942000-3.patch | 6.83 KB | Wim Leers |
#1 | edit_entity_ng-1942000-1.patch | 6.82 KB | Wim Leers |
Comments
Comment #1
Wim LeersComment #2
fagoI'd suggest to use getTranslation($langcode, FALSE) here, such that it works for untranslatable fields also. Else, patch looks good.
I guess this should work with the same data displayed, thus ideally we'd have a EntityLanguageDecorator that incorporates language fallbacks (as field API does now) here. But that's a separate task.
Comment #3
Wim LeersOk, made that one line change :)
Comment #4
fagothanks, I think this is ready then.
Comment #5
Wim Leers@fago: Thanks!
Dear core committer: please credit Berdir as well, he did the bulk of the work here.
Comment #6
Damien Tournoud CreditAttribution: Damien Tournoud commentedDoes that mean that Edit only works with EntityNG now? Does it make sense to support both?
Comment #7
BerdirYes, that's what it means but I don't think it makes sense to support both. The only remaining public non-NG entities are now terms and users and they aren't supported yet anyway because not all node types are ported to the new entity access API yet so edit.module can't use that yet and afaik only supports nodes due to that right now.
Comment #8
Wim Leers@Damien: Everything is being converted to EntityNG. Because node.module doesn't implement the new Entity Access API yet, Edit is currently confined to nodes anyway.
Comment #9
podarokLooks like this one #1939994: Complete conversion of nodes to the new Entity Field API is a blocker
Comment #10
webchickTagging.
Comment #11
Dries CreditAttribution: Dries commentedCommitted to 8.x. Thanks for fixing this.
It seems wrong that this broke so badly. However, it sounds like we're working on improving or fixing our test coverage in #1822000: Remove Drupal\field_test\Plugin\Entity\Type\TestEntity in favor of EntityTest.
Comment #12
webchickComment #13
webchickx
Comment #14.0
(not verified) CreditAttribution: commentedUpdated issue summary. Add Related