UPDATE: The issue is migrated from Entity Translation queue.

For an entity-translated node, we have publication statuses for the entire node ('node.status' db field - "Boolean indicating whether the node is published (visible to non-administrators)"), and for each translation ('entity_translation.status' - "Boolean indicating whether the translation is published (visible to non-administrators)").
While 'node.status' does indeed control node visibility to non-administrators, 'entity_translation.status' does not seem to work (all translations are visible for 'node.status'=1 and invisible for 'node.status'=1, regardless of the 'entity_translation.status' value).

CommentFileSizeAuthor
#6 et_weight.patch921 bytesOnkelTem
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

plach’s picture

Status: Active » Postponed (maintainer needs more info)

Please, confirm this still exists in the latest dev.

GN’s picture

Testing with version = "7.x-1.0-beta2+7-dev" of 2012-Dec-20
Yes, this behavior still exists:
visibility for non-administrators is controlled by the node publishing status ('node.status'), and does not depend on the translation publishing status (all translations are visible for 'node.status'=1 and invisible for 'node.status'=0, regardless of their 'entity_translation.status' values).

csedax90’s picture

It's the same in the latest dev versione... please fix it because is very problematic

plach’s picture

I just tried a clean installation of D7 + the latest dev. I have a published english node with an unpublished italian translation. The anonymous user can only see the english values both on node/1 and on it/node/1.

To fix this I need a more detailed explation of what the expected behavior is wrt the actual behavior. And most importantly the exact steps to reproduce the issue starting from a clean D7 installation and possibly installing additional modules (specify their versions!).

FiNeX’s picture

OnkelTem’s picture

Title: entity_translation.status does not affect visibility of translations to non-administrators » Unpublished translations are visible to non-administrators
Project: Entity Translation » Title
Component: Base system » Code
Status: Postponed (maintainer needs more info) » Needs review
FileSize
921 bytes

I found the reason why this may happen and it seems to be reproducible. Moving the issue to Title queue.

Prerequisites:
* Install Entity Translation module. Enable translation for a node type.
* Install Title module and enable title replacement for that node type.
* Create a node of that type, add a translation and make it unpublished.

What happens:
Unpublished translation is displayed when visiting node page on language different then original.

Correct behavior:
Original version should be displayed.

And this is what happens:

1. Title module changes implementations order and places itself to the top of implementations list in title_module_implements_alter().
2. Now when an entity is loaded and entity_load hook is triggered, title module takes the lead BEFORE entity_translation loads translations to the entity
3. Title module calls title_field_sync_get() which calls field_language():

For comfortable viewing use this gist instead.


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

4. Now when the node is viewed and field_langauge() is called again (from field_attach_prepare_view()), it returns wrong language data.

I'm not sure about the proper fix, but I think that Title module's entity_load hook should be triggered AFTER Entity Translation's hook.

Possible patch is provided.

OnkelTem’s picture

Issue summary: View changes
alcroito’s picture

This might be a duplicate of #2085457: Wrong cache is initialized in field_language() ? That patch clears the field_language cache that is populated by the title field, so then it should show the correct language data?

pifagor’s picture

pifagor’s picture

Status: Needs review » Reviewed & tested by the community

  • pifagor committed e5da41d on 7.x-1.x authored by OnkelTem
    Issue #1762064 by OnkelTem, pifagor, GN, plach, FiNeX, sedax, Placinta:...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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