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

nonsie - August 27, 2009 - 17:34
Status:active» postponed (maintainer needs more info)

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

kotu - August 28, 2009 - 08:04
Status:postponed (maintainer needs more info)» active

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

kotu - August 28, 2009 - 08:27
Priority:critical» normal

#4

nonsie - August 28, 2009 - 16:03

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

nonsie - August 28, 2009 - 16:04
Status:active» postponed (maintainer needs more info)

#6

agentrickard - August 30, 2009 - 17:28
Version:6.x-2.0-rc8» 6.x-2.0-rc9

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

nirbhasa - September 10, 2009 - 04:44

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

agentrickard - September 10, 2009 - 13:31

@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

nirbhasa - September 10, 2009 - 19:04

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.

AttachmentSize
events_sitewide_listing.view_.txt 5.78 KB

#10

agentrickard - September 10, 2009 - 19:32

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

nirbhasa - September 10, 2009 - 20:05

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.)

AttachmentSize
views query.txt 2.85 KB

#12

agentrickard - September 10, 2009 - 20:21

@nirbhasa, Thanks for that. It looks like you are just having a node access issue, which is separate, and may be by design.

#13

nirbhasa - September 10, 2009 - 22: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

agentrickard - September 14, 2009 - 19:44
Status:postponed (maintainer needs more info)» active

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

Bartezz - September 14, 2009 - 20:58

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

agentrickard - September 14, 2009 - 21:49

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

Bartezz - September 21, 2009 - 14:06

I have tried and failed.... is there any progress on this?

Cheers

#18

agentrickard - October 4, 2009 - 21:57
Category:support request» bug report
Status:active» needs review

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.

AttachmentSize
561282-views-filtering.patch 894 bytes

#19

Bartezz - October 5, 2009 - 09:43

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

agentrickard - October 5, 2009 - 15:03

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

Bartezz - October 5, 2009 - 19:24

Will try this tomorrow and post my findings!
Thanx for the quick response!

Cheers

#22

Bartezz - October 6, 2009 - 08:28

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

AttachmentSize
view-export-Domain Access Available on current domain True .txt 6.37 KB
view-export-Domain Access Domain ID = Current Domain .txt 6.41 KB

#23

agentrickard - October 6, 2009 - 13:45

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

Bartezz - October 6, 2009 - 18:20

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

Bartezz - October 8, 2009 - 11:29

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

agentrickard - October 8, 2009 - 14:02

The patch makes the distinct == yes work correctly, AFAIK. So you need it.

#27

Bartezz - October 8, 2009 - 14:13

That worked without the patch as well... maybe it helps in other cases where 'distinct = yes' isn't alwys respected...

Cheers

#28

agentrickard - October 24, 2009 - 15:38
Status:needs review» fixed

Committed to HEAD.

#29

System Message - November 7, 2009 - 15:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#30

bleen18 - November 13, 2009 - 21:33
Status:closed» active

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:

  • We have 4 domains (distinct domains, not subdomains but I don't think that matters) that look & function 99% the same.
  • For all content one-and-only-one domain is checked (available on all affiliates is never checked)

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?

AttachmentSize
highest-rated.view_.txt 5.48 KB
query.sql_.txt 1.74 KB

#31

agentrickard - November 13, 2009 - 22:04
Status:active» fixed

Open a new issue please.

#32

bleen18 - November 16, 2009 - 14:52

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

System Message - November 30, 2009 - 15:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.