Views are filtered out even if filter is not set
kotu - August 27, 2009 - 16:41
| Project: | Domain Access |
| Version: | 6.x-2.0-rc9 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Hello Everyone,
I have problem with integration with Views module.
All content of each view is restricted to be available at particular domain but sometimes I wish to list a content from different one.
Generally speaking my views are being filtered regardless of using "Domain Access: Available on current domain" filter.
In each case view query preview shows proper SQL statement but domain restrictions are adding to query (in WHERE clause ) on the very end of Drupal precessing.
Please help! :)

#1
Does the user have access to the content from that other domain? There's a similar discussion here - http://drupal.org/node/560156#comment-1974338
#2
Yes, user is able to access content (but not directly on this domain) and my view is accessible as well, there are standard news nodes without any restrictions in my view.
I don't have any warnings or error messages (like in #560156: Restricting View access by domain) and users do have an access to view but as I said before some of nodes (nodes which are not set to be available on domain when view is showing up) are filtered out are not displaying :/
Particular views should be able to display nodes from other domain without any restrictions if I haven't set filter like 'Domain Access: Available on current domain' up, am I right !?
#3
#4
So what are you saying is that the nodes you are trying to show in the view are not published to the domain the view is on?
#5
#6
I ran into something like this the other day setting up for DrupalCON, I think caused by the default JOIN to {domain_access} on 'domain_id' realm when connecting to the node table. Check the preview query.
#7
I can replicate this issue, perhaps I can help clarify:
I have some nodes at http://domain1.test.com which I wish to highlight using views on the main domain (http://www.test.com)
So I create a view (again, no domain filters) with page display with alias /pagedisplay. Viewing the page as anonymous user, I can see the nodes at http://domain1.test.com/pagedisplay but the view returns no results for http://www.test.com/pagedisplay (or any other domain).
If I log in as overall site admin, I can see the view results on both domains.
If I add 'pagedisplay' in the special page requests I can see the view results at both http://domain1.test.com/pagedisplay and http://www.test.com/pagedisplay as anonymous user.
However, for anonymous users block views don't show up on the main domain, and also the 'insert view' filter desnt work either.
(ps as a quick workaround to replace the insert views filter, does anyone know how to insert the contents of a URL (eg pagedisplay) into another node? I tried Panels but it only takes node arguments, not url paths :) )
#8
@nirbahsa
I think that is a separate issue, caused by normal Node Access behavior. Do you have Domain Strict turned on?
What we're talking about are extra JOINs added to Views queries when they shouldn't be. We would need to see a copy of the View and the queries it is writing to confirm.
#9
Hmm...
I dont have Domain Strict turned on, and all nodes in the site are visible to anonymous users. Also, as I mentioned above, the 'Page' view displays nodes from all domains if I add its URL to 'special page requests'
My setup seems to be similar to kotu, in that users can access all content, but they have to go to the relevant domain to do so. But they dont have to be members of any domain in order to view content.
In any case, I am attaching the view here. Let me know if it is indeed seperate, and I'll scurry off to open another issue.
#10
Everything you describe is by design.
1) Also, as I mentioned above, the 'Page' view displays nodes from all domains if I add its URL to 'special page requests'
Yes, that is the purpose of that setting. It disables DA's access rules.
2) My setup seems to be similar to kotu, in that users can access all content, but they have to go to the relevant domain to do so. But they dont have to be members of any domain in order to view content.
Yes, unless you use Domain Strict, it doesn't matter whether a user is a member of a domain or not.
These are both default behaviors, and well documented.
The question (which you can answer by looking at the Preview query that Views generates) is: Does Domain Access add a JOIN to your Views query even when you don't want it to?
#11
Hi, here's the views query. Nothing seems untoward (no extra joins). One thing that is interesting is I included the additional queries, and drupal_lookup_path looks for the URL aliases where the language is in the same domain as where the view is called. I have each domain assigned to a seperate language.
(edit: however, as a test I moved the nodes to be called in the view to the same domain where the view was being displayed without changing the language, and it worked.)
#12
@nirbhasa, Thanks for that. It looks like you are just having a node access issue, which is separate, and may be by design.
#13
I was busy pouring out my woes with this to a friend when I thought of a workaround: I added the URL of the page where the 'insert view' filter is embedded to the 'special page requests', and lo, content from all domains is displayed in the view! The same goes for block views, just add the url of the page where the block view appears.
And...the page still only shows up on that domain! This may be because of the fact that I have domain-based language negotiation (and URL aliases are language dependent).
I guess it doesnt solve the problem at hand, but I though it might be a good thing to post until the issue gets sorted.
@agentrickard - Thanks for all your help, and for such a great module.
#14
See #577008: "Domain Access: Available on current domain True" does not show results if not individually checked on node (marked duplicate) for a good example View that illustrates the problem.
#15
The issue agentrickard is pointing to is my issue.
What I've found that in domain_views_handler_filter_domain_access_current_all.inc. there's this line;
$this->query->add_where($this->options['group'], "(($table.realm = 'domain_id' AND $table.$this->real_field ". '=' ." ***CURRENT_DOMAIN***) OR ($table.realm = 'domain_site' AND $table.$this->real_field = 0))");Causing the query to
LEFT JOIN sgz_domain_access domain_access ON node.nid = domain_access.nid AND domain_access.realm = 'domain_id'
It's this part "domain_access.realm = 'domain_id'", when I change it to domain_site everything works as expected.
Yet I think it shouldn't code like that.
This is my query (well the part that matters)
SELECT node.nid AS nid,...
FROM sgz_node node
LEFT JOIN sgz_domain_access domain_access ON node.nid = domain_access.nid AND domain_access.realm = 'domain_id'
WHERE (node.status <> 0) AND (node.type in ('nieuwsbericht')) AND (((domain_access.realm = 'domain_site')))
As you can see in the WHERE part it looks for a node of which it's realm column value in the domain_access table = domain_site, yet the JOIN sets the domain_access.realm value to 'domain_id' hardcoded. I'm no SQL wizzard but I think this is the problem.
Maybe anyone of you can come up with a fix?
Cheers
#16
It's not a SQL problem so much as a Views query builder problem. We have to put some checking in there before that JOIN is made.
#17
I have tried and failed.... is there any progress on this?
Cheers
#18
It looks like the problem is the 'extra' field definition in the JOIN to the node table.
I can't remember why we put that in there. This patch removes it.
#19
Hi Agentrickard,
I've applied the patch to rc9 and my first findings are that nodes that are 'send to all affiliates' now show up double for user 1 and quadruple for anonymous users.
So:
- edit node
- publishing options: send to all affiliates
- publish to: primairy domain
- source domain: primairy domain
Then the view filter:
Node: Published Yes
Node: Type = News item
Domain Access: Available on current domain True
A workaround is to set the view to 'distinct = yes' but maybe there's an easy fix for it within the domain_views module.
The upside is that nodes are now being published to all affiliates just by checking 'send to all affiliates' so one doesn't have to check each individual 'publish to' subdomain any more! Nice one :)
Also the node is only listed once in the view on the subdomain. So the problem with double/quadruple listing is only with the source domain of the node as far as I can see!
Cheers,
Bartezz
#20
This may be a core bug. Try the patch here --> http://drupal.org/node/284392#comment-2103346
I think the extra fields stuff was a workaround for that bug.
You can also add the Domain Access filter for Domain Access: Access Type == 'domain_id'.
Attaching Views exports will be a big help in debugging.
#21
Will try this tomorrow and post my findings!
Thanx for the quick response!
Cheers
#22
Hey Agentrickard,
I've attached the exported views, I still have duplicates when viewing as user 1 and quadruple listings for anonymous.
For now I will use distinct = yes instead of patching core...
Cheers
#23
I still have duplicates-- That is _with_ the core patch?This can only really be fixed by patching core, AFAIK. And patching core is very high priority, that issue needs testers, and we expect a 6.15 release shortly.
#24
Hey agentrickard,
Will test the patch tomorrow then. Thought using ditinct = yes would be better in my case as patching core is not ideal I guess.
But understand the need of testing that patch... will test and post back.
Cheers
#25
I've applied the patch mentioned in #20 and cleared all caches but it had no effect :(
So I'll stick to distinct = yes for now...
Cheers
#26
The patch makes the distinct == yes work correctly, AFAIK. So you need it.
#27
That worked without the patch as well... maybe it helps in other cases where 'distinct = yes' isn't alwys respected...
Cheers
#28
Committed to HEAD.
#29
Automatically closed -- issue fixed for 2 weeks with no activity.
#30
I feel like the ultimate resolution to this ticket skewed a bit from the original poster's problem. I have a similar issue outlined below...
OUR SETUP:
WHAT WE WANT:
If a visitor goes to www.site1.com she should see the /node page but only the content for site1.com should be displayed (works great). In the RIGHT_RAIL of that page however, we want a block that includes links to the most popular content (as voted on by users via the fivestar module) from all 4 domains.
WHAT WE TRIED:
We created a view (attached) with no domain filters at all
The query that gets run is also attached
WHAT WE SEE:
If I'm viewing the block on www.site1.com then I only see the popular stories from site1
If I'm viewing the block on www.site2.com then I only see the popular stories from site2
Note: If i run the query directly in phpMyAdmin, I see the correct results
So... How do we cross-promote content across domains while still keeping the "main content area" segregated? Having all our content for several sites (even though they look and act very similar) in one database so it would be easy to do things like list the most popular content across domains was the the main attraction of using DomainAccess.
What is the correct way to accomplish this?
#31
Open a new issue please.
#32
If you are still having the same problem as the original post ... I'm continuing that issue here: #632438: Show domain 2 content on domain 1 in a block
#33
Automatically closed -- issue fixed for 2 weeks with no activity.