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:

  1. Change entity_metadata_field_get_language() to make it try to fetch te appropriate value even if $default_langcode is LANGUAGE_NONE.
  2. Change title_field_text_sync_get() to set $entity->language if it isn't present and use $entity->translations->original to do so (remove the property again after getting the value).
  3. Change EntityTranslationDefaultHandler::loadMultiple() to set $entity->language if it isn't present.
  4. Change entity_metadata_field_get_language() to check for $entity->translations->original too.

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

das-peter’s picture

I'd say following issue could bring the solution: #1495648: Introduce entity language support

elyobo’s picture

Component: Code » Base system

#1444966: Add langcode property in taxonomy schema has added the language field to the schema, but the problem remains.

das-peter’s picture

@elyobo: The issue you mentioned is for D8, but this issue here is about D7 ;)

elyobo’s picture

Good point. The taxonomy vocabulary and the taxonomy_term_data tables in D7 both have language fields, what else is needed here then?

plach’s picture

Status: Active » Postponed

I this issue should definitely be solved by #1495648: Introduce entity language support. Postponing it on that one.

plach’s picture

Status: Postponed » Postponed (maintainer needs more info)

This should be fixed with latest dev versions of Title and ET.

plach’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

This should be fixed in the upcoming dev snapshot.
Reopen if needed.