- Merge request !77Add test to ensure views relationships also exclude trashed content. β (Merged) created by bkosborne
Views relationships (joins) are missing the trash deleted check. This allows deleted content to show in views listings.
The current views query alter logic only adds the deleted check on the base table, but it should also do it for relationships.
Expectation: Only Article C is listed.
Reality: Article B and Article C are listed, even though Article B is in the trash.
This is the query produced:
SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid, field_related_articles_node_field_data.nid AS field_related_articles_node_field_data_nid
FROM node_field_data node_field_data
INNER JOIN node__field_related_articles node__field_related_articles ON node_field_data.nid = node__field_related_articles.field_related_articles_target_id AND node__field_related_articles.deleted = '0'
INNER JOIN node_field_data field_related_articles_node_field_data ON node__field_related_articles.entity_id = field_related_articles_node_field_data.nid
WHERE (((node_field_data.nid = '4')) AND (node_field_data.deleted IS NULL)) AND (node_field_data.status = '1')
ORDER BY node_field_data_created DESC
LIMIT 5 OFFSET 0
This is what it should be to exclude the deleted articles in the join:
SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid, field_related_articles_node_field_data.nid AS field_related_articles_node_field_data_nid
FROM node_field_data node_field_data
INNER JOIN node__field_related_articles node__field_related_articles ON node_field_data.nid = node__field_related_articles.field_related_articles_target_id AND node__field_related_articles.deleted = '0'
INNER JOIN node_field_data field_related_articles_node_field_data ON node__field_related_articles.entity_id = field_related_articles_node_field_data.nid AND field_related_articles_node_field_data.deleted IS NULL
WHERE (((node_field_data.nid = '4')) AND (node_field_data.deleted IS NULL)) AND (node_field_data.status = '1')
ORDER BY node_field_data_created DESC
LIMIT 5 OFFSET 0
I'm not very familiar with views query alters, but I think we need to somehow alter the join to add the additional condition for deleted is NULL check.
Active
3.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.