Multilingual wrong behaviors dealing with Unpublished nodes

Created on 19 June 2023, over 1 year ago
Updated 10 August 2023, about 1 year ago

Problem/Motivation

the module doesn't work properly with multilingual nodes when dealing with Unpublished nodes

Steps to reproduce

when you unpublish a node that has a translation, all translation and origin language become unaccessible, and if you publish a node all translation and origin language became accessible even if the translation/origin language is unpublished.

🐛 Bug report
Status

Active

Version

3.1

Component

Code

Created by

🇯🇴Jordan Ahmad Khader

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Ahmad Khader
  • 🇯🇴Jordan Ahmad Khader

    hi,
    first of all, I don't see how using a query to get langcode $this->accessStorageService->getLangCode($node->id()) is necessary also it always returns source node (original language), not langCode

  • 🇯🇴Jordan Ahmad Khader

    After further investigating the cause of this issue, I discovered the following:

    public function getNidsByTidsForPublishedNodes($tids) {
      if (!empty($tids)) {
        $query = $this->database->select('taxonomy_index', 'ti')
            ->fields('ti', ['nid'])
            ->condition('ti.tid', $tids, 'IN');
    
        $nids = $query->execute()
          ->fetchCol();
    
        return array_unique($nids);
      } else {
        return [];
      }
    }

    Specifically, the line $query = $this->database->select('taxonomy_index', 'ti') is causing an issue with unpublished nodes that have translations. When a node is unpublished, the node and all its translations are removed from the record in the taxonomy_index table. This issue is discussed at https://www.drupal.org/project/drupal/issues/962664 Taxonomy Index for unpublished entities Needs work . After applying the patch with the patch mentioned in comment #2, the module works as intended.

    After applying the patch, the records of translation nodes inside the taxonomy_index table are no longer affected by the unpublishing of origin nodes or other translations.

  • 🇫🇮Finland joey-santiago

    This also has to do with this issue i created last year. Maybe we can work at this together?

    https://www.drupal.org/project/permissions_by_term/issues/3308318 🐛 Access for node is removed when an unpublished translation is added Needs review

    Whit the patch you find there something works better, but we just found out other things are still broken. For example if you add a restriction for a node, then you create an unpublished translation, then everything becomes accessible.

    Maybe this issue here should be marked as duplicated and we should join forces?

Production build 0.71.5 2024