"unpublished nodes" don't show up on node/%node/translate for users where uid ≠ 0 as soon as modules are installed that implement hook_node_grants
I spent quite a while looking into what causes this issue, and succesfully reproduced it on a clean install of 7.14 and 7.x-dev.
These are the steps to reproduce:

- perform a fresh install of Drupal 7.14
- Enable locale and content_translation modules

- Give "authenticated user" the following permissions:
-- create/edit own/delete own content for Basic Page
-- translate content
-- view own published content

- For the basic page content type, enable Multilingual support: " Enabled, with translation"

- in "Regional and languages", add a language (I added Dutch (NL))

- Create a new user johndoe

- Log in as johndoe

- Create a basic page in the default language (EN)
- Go to the translate tab of that page and add a Dutch translation
- Go to the translate tab from the translation. Remember what you see.

- Log back in as admin

- Unpublish the original node (node/1)

- Log back in as johndoe

- Check the translate tab on node/1/translate and node/2/translate. Everything looks normal.

- Logged in as admin again, enable any module that implements hook_node_grants (e.g.: content_access, og_access, nodeaccess_userreference, ..)

- Rebuild node access

- Log back in as johndoe

- Check the translate tab on node/1/translate and node/2/translate. What the @é$%! Why does English appear "not translated" ?
=> THE PROBLEM: our unpublished translations won't appear any more

- Disable any modules that implement hook_node_grants, recheck the page.. Everything back to normal.

A little background info (from my point of view, might be completely wrong)
in translation.module, translation_node_get_translations() adds a node_access tag.
This will be handled in node.module by _node_query_node_access_alter(). Here the simple query get extra conditions added . This is no problem at all, but one of the last lines of code $subquery->where("$nalias.$field = na.nid"); seems to suggest that a node must always have an entry in the node_access table, which seems not to be the case?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

What module are you using that applies hook_node_grants()?

agentrickard’s picture

There are a couple of issues here, including the fact that a node access query cannot account for the "view own unpublished nodes" permission. That has to be fixed by looping through and checking node_access() on each node.

agentrickard’s picture

Status: Active » Needs review
FileSize
855 bytes

Here is one potential solution, which I just discussed with @xjm.

You cannot actually use a query to determine who can view these nodes, precisely because of the "view unpublished." (Side note: the proper behavior of hook_node_access_records() is to store $node->status in the grant_view column.)

So this patch moves the node access check out of the query and to the foreach loop, which should fix your issue. However, the Translate tab will vanish if ou cannot view any of the translations -- and it is also possible that certain languages will vanish if the user has no permission. We might want to clean that up as well.

agentrickard’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +i18n

This will need to be fixed in Drupal 8 first. Tagging for translation team.

kupide’s picture

#2 works for me. Thx !!

kupide’s picture

Issue summary: View changes

added: "as soon as modules are installed that implement hook_node_grants" for clarity

alansaviolobo’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

chishah92’s picture

Component: translation.module » ajax system
Assigned: Unassigned » chishah92
chishah92’s picture

Assigned: chishah92 » Unassigned
bogdan.racz’s picture

Component: ajax system » content_translation.module
Issue tags: +Needs issue summary update

I wasn't able to replicate the problem, with the steps above, event though they we're specified for Drupal 7.
I guess it needs an issue update, or simply close it.

rv0’s picture

If the issue isn't there in D8, shouldn't it be set to D7 again instead of closing it?

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

hitesh-jain’s picture

Assigned: Unassigned » hitesh-jain
hitesh-jain’s picture

Assigned: hitesh-jain » Unassigned
flyke’s picture

I have this problem on a Drupal 8.2.3 site.

- site with 3 languages, and 2 users with the role 'content editor'
- content editor 1 creates a node (in default language) and saves it as unpublished
- content editor 2 can edit the node but cannot translate it (translate tab is missing and translate option is also missing from the operations in the backoffice node overview page).
- If content editor 1 or 2 publish the node, then content editor 2 can translate it
- so now the node is in default language (1), and also succesful translated to language 2
- most weird part: if you unpublish language 1, and then try to add a translation via language 2, you get an access denied error

So in short:
problem 1: non admin user cannot translate unpublished content
problem 2: non admin user cannot translate a node if the source node is unpublished

For reference: the permissions of my content editor role:
NO: Administer translation settings
YES: Create translations
YES: Delete translations
YES: Edit translations
YES: Translate any entity
YES: Translate Basic page content

(the testing above is from nodes of the type basic page)

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

anish.a’s picture

This needs testing and have to know the steps to reproduce. I am not sure if the issue is relevant anymore.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

weseze’s picture

Still relevant in latest 8.9.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 9.5.x-dev » 7.x-dev
Issue tags: +Bug Smash Initiative

This was a bugsmash daily target yestersay. Lendude responded saying that they are currently "working on a site that uses node grants a LOT and also uses translations for all content types, this is not an issue". That sites does "use content moderation, so ‘unpublished’ becomes a bit more vague". They looked at the D7 and D8 code and determined that this is a “different nid for a translation” problem. And concluding this issue belongs in Drupal 7.

They also pointed out that the problem in #15, is a different problem and perhaps needs a separate issue. For that, I tested on Drupal 10.1.x, standard install. I was not able to follow the second step. "content editor 1 creates a node (in default language) and saves it as unpublished'. The content editor does not have permission to set the content as unpublished.

This is summarized into two problems in that comment.

  • problem 1: non admin user cannot translate unpublished content
  • problem 2: non admin user cannot translate a node if the source node is unpublished

And I found that not to be true. A non admin user can translate unpublished content if it is their own content. And I deleted the first language and the author, a content editor, was able to add a translation in the second language without error.

All together, I think this is working as designed. If I am wrong, open a new issue and provide steps to reproduce.

I am moving this to Drupal 7.