The call to entity_language($entity_type, $entity) on a hook_field_access() throws fatal errors for some fields. This occurs because the call $langcode = $handler->getFormLanguage(); is not securely wrapped for avoid non object method calls.

// This function leaves on entity_translation.module
function entity_translation_language($entity_type, $entity) {
  $handler = entity_translation_get_handler($entity_type, $entity);
  $langcode = $handler->getFormLanguage();
  return !empty($langcode) ? $langcode : $handler->getLanguage();
}

The following changes avoid this problem.

// This function leaves on entity_translation.module
function entity_translation_language($entity_type, $entity) {
  $handler = entity_translation_get_handler($entity_type, $entity);
  if (empty($handler)) {
    return LANGUAGE_NONE;
  }
  $langcode = $handler->getFormLanguage();
  return !empty($langcode) ? $langcode : $handler->getLanguage();
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brunoric created an issue. See original summary.

brunoric’s picture

The changes on issue description follows as a patch.

brunoric’s picture

Status: Active » Needs review
brunoric’s picture

Assigned: Unassigned » brunoric
Anonymous’s picture

It's working for me.

cebasqueira’s picture

Works!!!!

brunoric’s picture

Status: Needs review » Reviewed & tested by the community
mmchristoph’s picture

Perfect!

  • brunoric authored 37d4f63 on 7.x-1.x
    Issue #2648062 by brunoric, cebasqueira, lucasr, mmchristoph: Fixed...
plach’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.