Hello . I have problem with new security update of Views 7.x-3.8 .
https://drupal.org/node/2271809

I use relation with Entity translation in view. In error log :
Fatal error: Call to a member function getLabel() on a non-object in sites/all/modules/entity_translation/views/entity_translation_handler_field_label.inc on line 71

Comments

plach’s picture

Priority: Critical » Major
Status: Active » Postponed (maintainer needs more info)
ciss’s picture

In our case this seems to have resulted from stale entries in the entity_translation table:

  1. When creating an entity_translation view it would return these stale entries that had no corresponding entries in the node table.
  2. Adding the label handler, entity_translation_handler_field_label::post_execute() then attempts to load these node entities and add them to entity_translation_handler_field_label::$entities. As a result there will be no entries for the passed ids.
  3. entity_translation_handler_field_label::render() then accesses $this->entities[$entity_type][$entity_id] and fetches the handler. Assuming the handler to be present (even though it isn't), the code continues to call $handler->getLabel() on a NULL value.
ciss’s picture

Priority: Major » Normal
Status: Postponed (maintainer needs more info) » Active

Setting to active and normal. I'm not sure wether this is something that needs to be caught inside the handler, or should be dealt with in a different way (or not at all).

ciss’s picture

Version: 7.x-1.0-beta3 » 7.x-1.x-dev
ciss’s picture

During development we often end up with lots of stale entries as requests are often interrupted. With these entries present it becomes impossible to use entity translation views.

We've been using the following code to prune these stale entries:

function MODULE_delete_stale_entries() {
  $deletions = array();

  foreach (entity_get_info() as $entity_type => $entity_info) {
    if (entity_translation_enabled($entity_type)) {
      $base_table = $entity_info['base table'];
      $id_key = $entity_info['entity keys']['id'];

      foreach(array('entity_translation', 'entity_translation_revision') as $table) {
        $not_exists_query = db_select($base_table, 'b')
          ->fields('b')
          ->where("b.$id_key = $table.entity_id");

        $count = db_delete($table)
          ->condition('entity_type', $entity_type)
          ->notExists($not_exists_query)
          ->execute();
        if($count) {
          $deletions[$entity_type][$table] = $count;
        }
      }
    }
  }
  return $deletions;
}