Problem/Motivation

Group module create a view called "Group nodes (content)" (group_nodes) which should display all nodes related to the group.

Unfortunately this view is bugged because it displays wrong data out of the box (just tried on a new fresh D9/Group2 installation.

More precisely the JOIN doesn't correctly match the data.

This is the query executed by the view for an example group with ID=1:

SELECT
    node_field_data.nid AS nid,
    group_relationship_field_data_node_field_data.id AS group_relationship_field_data_node_field_data_id
FROM
    node_field_data node_field_data
INNER JOIN group_relationship_field_data group_relationship_field_data_node_field_data ON
    node_field_data.nid = group_relationship_field_data_node_field_data.entity_id
WHERE
    (
        group_relationship_field_data_node_field_data.gid = '1'
    )
ORDER BY
    node_field_data.changed
DESC
LIMIT 50 OFFSET 0

As you can see, it matches all the node IDs with the relationship data table which, by default, contains both nodes and users.

Steps to reproduce

Let's say that on a fresh installation you have the following data:

  • One group configured to accept article nodes
  • One user with ID=1, who also is the member of the group, in my case it's the group creator/admin
  • One article node with ID=1, assigned to the group

The group_relationship_field_data will contains two records: one for the membership relation, and one with the content relation (column plugin_id).

The entity_id column has the same value (both user and node IDs are 1).

The JOIN will get both and they will both related to the node_field_data, creating an obvious problem: when an group user has the same ID of a node, this node will be shown.

Proposed resolution

One simple solution is to force the view to use a LEFT JOIN (don't know if it is possible).

Another solution is to enforce the view relationship "content relation", but it has to be manually added because by default no content types are added to tho the group type settings.

Until a solution is not provided I suggest to add this issue to the documentation.

Comments

FiNeX created an issue. See original summary.

artyom hovasapyan’s picture

kristiaanvandeneynde’s picture

Status: Active » Closed (duplicate)
Related issues: +#3315779: Weird behavior. Nodes are appearing in a group when add a member.

Thanks for the detailed explanation, will mark as duplicate of the other issue.