- 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?