Problem/Motivation
The modules entity, entity_translation, title interaction on entities without a language property (e.g. taxonomy terms) broke as of this #1376126: Fix language handling for translatable fields (commit).
Example call stack:
entity_label()
title_entity_label()
title_field_text_sync_get()
$wrapper->language($langcode)
$wrapper->{$info['field']['field_name']}->raw()
entity_metadata_field_property_get()
$langcode = entity_metadata_field_get_language($entity_type, $entity, $field, $langcode, TRUE);
If we deal with e.g taxonomy terms the handling fails because $wrapper->language($langcode) as used in title_field_text_sync_get()<code> has no effect on <code>entity_metadata_field_get_language().
entity_metadata_field_get_language() only checks the $entity->language property.
As far as I can tell this issue is related to #1260640: Improve field language API DX.
Question now is how we can solve this right now, because it's unlikely that 1260640 is fixed soon.
Proposed resolution
There are several possibilities:
- Change
entity_metadata_field_get_language()to make it try to fetch te appropriate value even if$default_langcodeisLANGUAGE_NONE. - Change
title_field_text_sync_get()to set$entity->languageif it isn't present and use$entity->translations->originalto do so (remove the property again after getting the value). - Change
EntityTranslationDefaultHandler::loadMultiple()to set$entity->languageif it isn't present. - Change
entity_metadata_field_get_language()to check for$entity->translations->originaltoo.
1 + 4 are likely not ideal because it changes otherwise correctly working code / introduces a "dependency".
2 isn't a very general approach.
3 changes the entity structure of entities without a language property. That could have nasty side-effects.
I'd say to solve this, we need to consider following slogan: A good compromise is it, if nobody really is pleased ;)
User interface changes
none
API changes
Not API, but entity structures without a language property could become one, what could cause nasty side-effects.
Comments
Comment #1
das-peter commentedI'd say following issue could bring the solution: #1495648: Introduce entity language support
Comment #2
elyobo commented#1444966: Add langcode property in taxonomy schema has added the language field to the schema, but the problem remains.
Comment #3
das-peter commented@elyobo: The issue you mentioned is for D8, but this issue here is about D7 ;)
Comment #4
elyobo commentedGood point. The taxonomy vocabulary and the taxonomy_term_data tables in D7 both have language fields, what else is needed here then?
Comment #5
plachI this issue should definitely be solved by #1495648: Introduce entity language support. Postponing it on that one.
Comment #6
plachThis should be fixed with latest dev versions of Title and ET.
Comment #7
plachThis should be fixed in the upcoming dev snapshot.
Reopen if needed.