Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
field system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 Jul 2013 at 01:42 UTC
Updated:
29 Jul 2014 at 22:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
plachTotally :)
Comment #2
fagoAgreed - totally ;-)
Comment #3
yched commentedPatch, then.
Comment #4
plachCurrently this is correct. The end goal is passing around the correct translation object, so we don't have to instantiate it here.
Comment #5
yched commentedWell, in this case (node_token()), both the $node and the $langcode are received as entries in the $options param.
Are there plans to reshuffle tokens parsing & processing so that the $node directly arrives in the right language ?
Anyway, as you say, this seems the right code for the current state of HEAD ?
Comment #7
plachI think we should simply get rid of the $langcode options entry: if you can specify it, you can even pass the correct translation object. Otherwise things will apply to the default language which is the intended behavior.
Well, now that I look more closely I think there would be a problem if $langcode is NULL (and right now it can): we can either replace the NULL value in line 101 with
Language::LANGCODE_DEFAULTor makeEntityNG::getTranslation()interpret a NULL value asLanguage::LANGCODE_DEFAULT. Actually I am not sure we want to encourage passing unchecked langcode values.Comment #8
plachcrosspost
Comment #9
yched commentedHmm. I'm not changing the way tokens work in this patch :-)
Well,
$entity->getTranslation()would look weird, woulnd't it ?Comment #11
yched commented#9: field_get_items-2051721-9.patch queued for re-testing.
Comment #12
plachNo, sure, I was just thinking loud :)
Overall this looks good to me, can you explain why these changes were needed? Aren't __get() and get() functionally the same when we come to regular fields?
Comment #13
yched commentedI was mixing the "$items = $entity->$field_name" syntax (which returns $items as nested arrays) with "$items->method() / $item->$column".
Need to pick one. Matter of taste, I picked the object syntax, since this is what most of the code works with.
I find this quite confusing, BTW ($entity->$field_name returns plain arrays, $entity->get($field_name) returns objects) :-)
Comment #14
plachI think the BC decorator is the culprit (as usual),
EntityNG::get($field_name)andEntityNG::__get($field_name)should return exactly the same value (a field item list object).Comment #15
yched commentedYes, I wasn't sure about that, which is also why I went with the syntax that consistently returns objects :-)
Comment #16
catchI think we should mark this @deprecated now we're in API freeze. It's not a one-line wrapper so it'll need to go before release but we should give people some warning.
Comment #17
berdirI wouldn't be surprised if this would be broken too but we just don't have any test coverage...
Comment #18
yched commented@catch: added @deprecated. How do we keep track of which @deprecated we want to remove before release ?
@Berdir: indeed. Doubly broken, since taxo fields 'tid' property has been renamed 'target_id' a while ago...
Comment #20
berdir#18: field_get_items-2051721-18.patch queued for re-testing.
Comment #21
catch@yched we don't have a way (yet). I opened #2042165: Add a 'deprecated' module that includes deprecated functions only when enabled to discuss stuff that's left in.
Comment #22
plachBack to RTBC?
Comment #23
yched commentedHeh, yes, why not ;-)
Comment #24
plachComment #25
catchCommitted/pushed to 8.x, thanks!
Needs change notice for the deprecation.
Comment #26
yched commentedCreated a change notice - this mostly links back to the change notice for the Entity Translation API.
Comment #27
plachLooks good :)