When I choose a reverse relationship (relate all content that references the node) in Views, it should relate all the data from the referencing nodes and just not list that data if the original node is never referenced, but non-referenced nodes are eliminated from the results. I imagine the node_reference module parses the base table to only include referenced nodes and then relates the data, but it shouldn't do this unless the "Require this relationship" option is chosen in Views. I would be happy to help fix this, but I don't understand the modules well enough to do it on my own. This is a major issue for me because it eliminates an entire section of nodes that I need and there is no good way to get them back since the relationship eliminates them in code.

Comments

jdavidkennedy’s picture

Same issue.

mxh’s picture

confirming this issue. I tried Corresponding node reference module to see if the issue remains when directly use reference field of the nodes in the view, but the result is the same: only items are shown which have a value in the reference field.

This behaviour should only appear when you activate the force relationship button. Can anyone help us?

mxh’s picture

Two possible workarounds:

- Use revision view instead of node view to work with historical references relationship.
- Use Views PHP module (very difficult!).

jeni_dc’s picture

I've noticed this as well and I haven't investigated if this could be a references, or a views issue.

One thing that has worked for me is to disable SQL rewriting in the view. It's under "Query settings" in the "Other" section of your view's advanced settings.

If you go this route make sure to read the warning that comes up about this disabling node access restrictions. In my case the view was set up to only show published nodes of a publicly available content type, so I don't think there's any reason to worry.

Another workaround that comes to mind is to create two views. View 1 is the referenced content type, and View 2 is the content type doing the referencing. In view 1 make sure you have a NID field which then gets passed to a reference contextual filter in view 2. View 2 is then embedded in view 1 either through templates/preprocessing or through Views Field View. I haven't tested that with this particular issue, but in theory I think it would work.

mxh’s picture

Disabling SQL rewriting just bypasses the node_access logic. This issue won't be solved with this, because you won't see the non-referenced nodes anyway, regardless if you're an admin or a guest.
The problem here is, that not selecting the "force relationship" setting, the non-referenced nodes are still not being shown.

It works as designed when you are a user who don't have permission to view a referenced node. The result: You won't see the whole record in this view. I think this should also be improved in some way, being able to determine if hide whole record or just mark the reference field as empty if no permission exists, would be nice... but this is offtopic.

Both workarounds with Views PHP or Views Field View require a lot of memory usage, that means those should be used when you don't display more than about 100 records at once. Unfortunately I had a lot of memory exhausting problems with both modules and had to use some other workarounds to finally get it work.

tedfordgif’s picture

I believe this is a duplicate of #1349080: node_access filters out accessible nodes when node is left joined and #1222324: Fix query access control on relationships (comments). You can confirm this by checking the SQL generated when the view is run as user 1 and a non-privileged user. If the only differences are EXISTS subqueries involving node_access, then this is a duplicate and should be closed.

mxh’s picture

I can confirm this, this is a duplicate of #1349080: Items in Views not appearing even when "Require this relationship" is not selected. Thanks tedfordgif for clarification.

mxh’s picture

Status: Active » Closed (duplicate)