If I un publish a particular translation, entire node got unpublished

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nijinanijil created an issue. See original summary.

agentrickard’s picture

Component: - Domain Conf » Code
Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

I need a proper, repeatable report please.

* What modules do you have installed?
* What steps did you take to produce the behavior?
* Why do you suspect Domain as the cause?

Please see the submission guidelines at https://www.drupal.org/issue-queue/how-to

nijinanijil’s picture

Hi,

I am also facing the same issue. Un publish translation option was working until I set up domain access. When you un publish a particular translation the entire node get un-published after setting up domain access.

Thanks
Nijil

nijinanijil’s picture

Steps to reproduce

Scenario 1

1) Install multi lingual module and add an additional language say 'ja'

2) Create an article and publish -- en version is published

3) Add translation for article and un publish -- ja version is un published. All works till here

4) Install domain access module. Rebuild content permissions

5) Access both the translations you can see both will show access denied

Scenario 2

1) Edit both the translations and un publish both.

2) Edit and Publish one of the translation. Both the translations will be available for guest users, even though one is published and one is un published.

Scenario 3

1) Edit both the translations and publish

2) Edit and un publish one of the translation. Both the translations will not be available for guest users

The value in the 'status' filed for both node and revision works as expected. But for the guest user the page translations are visible based on recent publish/un publish activity on that node (Any of the translations).

Drupal Version : 8.2.3

Modules Enabled : Multi Language, Domain Access

agentrickard’s picture

Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Active

Thanks. You can update issue status when providing requested information.

It sounds like the langcode option is not getting set correctly in the {node_access} table.

Can you report what records you have in {node_access} for the affected content?

agentrickard’s picture

I was able to replicate this from the instructions. It looks like a bug in handle permissions for unpublished content.

Here's what I have in node_access after the following steps:

* Create two nodes assigned to different domains
* Enable Dutch as a second language
* Translate node 1 into Dutch and save as unpublished.

mysql> select * from node_access;
+-----+----------+----------+------------+--------------------+------------+--------------+--------------+
| nid | langcode | fallback | gid        | realm              | grant_view | grant_update | grant_delete |
+-----+----------+----------+------------+--------------------+------------+--------------+--------------+
|   1 | en       |        0 | 1702463808 | domain_unpublished |          1 |            1 |            1 |
|   1 | nl       |        1 | 1702463808 | domain_unpublished |          1 |            1 |            1 |
|   2 | en       |        1 | 3589196716 | domain_id          |          1 |            1 |            1 |
+-----+----------+----------+------------+--------------------+------------+--------------+--------------+
3 rows in set (0.00 sec)

The English version of the node should have the domain_id realm, not domain_unpublished.

I also think the "fallback" value is incorrect.

agentrickard’s picture

There is a (to me) nasty omission in the definition of hook_node_access_records():

langcode: (optional) The language code of a specific translation of the node, if any. Modules may add this key to grant different access to different translations of a node, such that (e.g.) a particular group is granted access to edit the Catalan version of the node, but not the Hungarian version. If no value is provided, the langcode is set automatically from the $node parameter and the node's original language (if specified) is used as a fallback. Only specify multiple grant records with different languages for a node if the site has those languages configured.

Which means that we must supply the different access records for each node translation on save. That's pretty nasty. it is also possible, in theory, to have different domains per translation, but that isn't supported by the logic I think makes sense.

agentrickard’s picture

Status: Active » Needs review
FileSize
3.25 KB

OK, this is a tricky issue.

Technically, the node isn't unpublished, but its node access grants are. That means we have to save translation-specific records.

That opens up some potential issues:

* Access grants are now different per language -- which could cause confusion.
* I don't think the 'fallback' property is being set correctly in the {node_access} table. (In my test, it always sets to the language of the node being saved, not the site's default language translations.)

The fallback problem is compounded by 'domain_site' which is either on or off, so it doesn't get saved for all translations. I've worked around that by setting the value to 1 if it's disabled for a translation.

We have a few options here, the easiest of which is to not allow the field to be translated.

I'd appreciate some thoughtful review. We're also going to need tests.

agentrickard’s picture

FileSize
3.31 KB

Slightly better patch. There is no need to store domain_site as a negative value unless translations are enabled and present.

gurumurthy@drupal’s picture

Hi,

I have applied the patch but we got some issue while adding the content. I have shared the error blow.

Uncaught PHP Exception Symfony\Component\DependencyIn jection\Exception\ServiceNotFoundException: "You have requested a non-existent s ervice "domain.element_manager"." at /var/www/html/core/lib/Drupal/Component/Dep endencyInjection/Container.php line 157

Please let me know if you have any idea.

agentrickard’s picture

Sorry, I was on vacation.

What version of the code are you running? That service was added in alpha6 -- https://www.drupal.org/project/domain/releases/8.x-1.0-alpha6 -- and requires rebuilding the service container.

This patch is against the latest code (alpha7/dev).

gurumurthy@drupal’s picture

Thanks for the update. It is working fine.

agentrickard’s picture

Status: Needs review » Fixed

Thanks. This has been committed and pushed to drupal.org.

Status: Fixed » Closed (fixed)

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

Wouter Waeytens’s picture

Came across this issue when a source language when you unpublish the source language of a node. The node was not visible anymore in views. https://www.drupal.org/project/drupal/issues/3061782 fixed my issue.