If, using entity translation, I create a new translation of an FPP, but leave it unpublished, everyone can see this translation regardless of permissions.

Files: 
CommentFileSizeAuthor
#1 1931678-fpp_unpublished_translation-1.patch961 bytesdalin
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1931678-fpp_unpublished_translation-1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

Assigned:dalin» Unassigned
Status:Active» Needs review
StatusFileSize
new961 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1931678-fpp_unpublished_translation-1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

entity_translation_field_language_alter() checks whether the user has access to a translation. It first calls $handler->getTranslations() to load all the translation data. In the case of FPP this returns:

stdClass::__set_state(array(
   'original' => NULL,
   'data' =>
  array (
  ),
));

Whereas for a node we have

stdClass::__set_state(array(
   'original' => 'en',
   'data' =>
  array (
    'en' =>
    array (
      'entity_type' => 'node',
      'entity_id' => '263',
      'language' => 'en',
      'source' => '',
      'uid' => '74',
      'status' => '1',
      'translate' => '0',
      'created' => '1360348216',
      'changed' => '1361389418',
    ),
    'fr' =>
    array (
      'entity_type' => 'node',
      'entity_id' => '263',
      'language' => 'fr',
      'source' => 'en',
      'uid' => '3',
      'status' => '0',
      'translate' => '0',
      'created' => '1362190606',
      'changed' => '1362190606',
    ),
  ),
));

Looking deeper the inconsistency happens in EntityTranslationDefaultHandler->getTranslations()

Since $this->entity->{$translations_key} is in fact set.

The attached patch overrides this method to instead check $this->entity->{$translations_key}->original
I'm not sure if this data actually needs to be added earlier in the process.

Status:Needs review» Needs work

The last submitted patch, 1931678-fpp_unpublished_translation-1.patch, failed testing.

Is this a side effect of entity caching? I can't think of any other reason that hook_entity_load would not be used.