Skip to content

Instantly share code, notes, and snippets.

@OnkelTem
Created October 17, 2014 15:51
Show Gist options
  • Save OnkelTem/df97f2507ebcc35dfa7f to your computer and use it in GitHub Desktop.
Save OnkelTem/df97f2507ebcc35dfa7f to your computer and use it in GitHub Desktop.
<?php
function field_language($entity_type, $entity, $field_name = NULL, $langcode = NULL) {
$display_languages = &drupal_static(__FUNCTION__, array()); // *** This is cache for field languages
...
if (!isset($display_languages[$entity_type][$id][$langcode])) { // *** This is triggered only once, when cache is empty
...
drupal_alter('field_language', $display_language, $context);
->
function entity_translation_field_language_alter(&$display_language, $context) {
if (variable_get('locale_field_language_fallback', TRUE) && entity_translation_enabled($context['entity_type'])) {
...
$handler = entity_translation_get_handler($entity_type, $entity);
$translations = $handler->getTranslations(); // *** This is EMPTY as the translations are not loaded
...
if (isset($translations->data[$context['language']]) && !entity_translation_access($entity_type, $translations->data[$context['language']])) {
// *** NOT TRIGGERED, so no field language filtering/processing happens
<- // ** returns untouched entity
$display_languages[$entity_type][$id][$langcode] = $display_language; // *** Wrong language data drop into cache
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment