Hello!

First of all, I wanted to thank for this great module. It is very useful to distribute content between multiple domains.

On my site, I have a very strange problem and I'm not able to find a solution:

I have a lot of views on my front page that display f.ex. the first 10 articles. If I visit the frontpage as an anonymous user, then I see very node ad a duplicate (also if I use the distinct option in the views settings)

If I visit the same page as a logged in user, it works perfectly.

In the views I have a filter that limit the nodes to display only on the appropriated domain.

I searched now for hours and can provide the two queries (from query tracker)

logged in user (working):

SELECT node.nid AS nid, node_data_field_teaserimage.field_teaserimage_fid AS node_data_field_teaserimage_field_teaserimage_fid, node_data_field_teaserimage.field_teaserimage_list AS node_data_field_teaserimage_field_teaserimage_list, node_data_field_teaserimage.field_teaserimage_data AS node_data_field_teaserimage_field_teaserimage_data, node.type AS node_type, node.vid AS node_vid, node.title AS node_title, node_data_field_teasertext.field_teasertext_value AS node_data_field_teasertext_field_teasertext_value, node_data_field_teasertext.field_teasertext_format AS node_data_field_teasertext_field_teasertext_format, node.changed AS node_changed FROM node node LEFT JOIN content_type_story node_data_field_teaserimage ON node.vid = node_data_field_teaserimage.vid INNER JOIN files files_node_data_field_teaserimage ON node_data_field_teaserimage.field_teaserimage_fid = files_node_data_field_teaserimage.fid LEFT JOIN domain_access domain_access ON node.nid = domain_access.nid AND domain_access.realm = 'domain_id' LEFT JOIN content_type_story node_data_field_teasertext ON node.vid = node_data_field_teasertext.vid WHERE (node.type in ('story')) AND (node.status <> 0) AND (node.language ='de' OR node.language ='' OR node.language IS NULL) AND (((domain_access.realm = 'domain_id' AND domain_access.gid = 0) OR (domain_access.realm = 'domain_site' AND domain_access.gid = 0))) ORDER BY node_changed DESC LIMIT 0, 12

anonymous user / duplicates:

SELECT node.nid AS nid, node_data_field_teaserimage.field_teaserimage_fid AS node_data_field_teaserimage_field_teaserimage_fid, node_data_field_teaserimage.field_teaserimage_list AS node_data_field_teaserimage_field_teaserimage_list, node_data_field_teaserimage.field_teaserimage_data AS node_data_field_teaserimage_field_teaserimage_data, node.type AS node_type, node.vid AS node_vid, node.title AS node_title, node_data_field_teasertext.field_teasertext_value AS node_data_field_teasertext_field_teasertext_value, node_data_field_teasertext.field_teasertext_format AS node_data_field_teasertext_field_teasertext_format, node.changed AS node_changed FROM node node LEFT JOIN content_type_story node_data_field_teaserimage ON node.vid = node_data_field_teaserimage.vid INNER JOIN files files_node_data_field_teaserimage ON node_data_field_teaserimage.field_teaserimage_fid = files_node_data_field_teaserimage.fid LEFT JOIN domain_access domain_access ON node.nid = domain_access.nid AND domain_access.realm = 'domain_id' LEFT JOIN content_type_story node_data_field_teasertext ON node.vid = node_data_field_teasertext.vid INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.realm = 'all' AND na.gid = 0) OR (na.realm = 'domain_site' AND na.gid = 0) OR (na.realm = 'domain_id' AND na.gid = 0) OR (na.realm = 'private_author' AND na.gid = 0)) ) AND ( (node.type in ('story')) AND (node.status <> 0) AND (node.language ='de' OR node.language ='' OR node.language IS NULL) AND (((domain_access.realm = 'domain_id' AND domain_access.gid = 0) OR (domain_access.realm = 'domain_site' AND domain_access.gid = 0))) )ORDER BY node_changed DESC LIMIT 0, 12

Has someone an idea what could be wrong with the anonymous user?

btw:
I have the "private" module installed. One time I also tried to patch my drupal installation with the multi access patch and set "Check Domain Access in addition to other modules (AND)" in the settings. The result were blank pages. No results in views were displayed.

Comments

agentrickard’s picture

Note that the difference between the two queries is that one runs Node Access (through node_db_rewrite_sql) and the other does not. This is because node access rules do not apply to user 1 and users with the 'administer nodes' permission.

So the problem seems to be in the node access query, possibly in the combination of private and da.

Try turning off the filter. As a node access module, the nodes will essentially filter themselves. The problem is that node access won't apply to user 1 or administrators. Node Access queries should also get wrapped in DISTINCT by default.

FWIW, here's what the WHERE query looks like:

WHERE 
  (
    na.grant_view >= 1 AND 
    (
      (
        na.realm = 'all' AND na.gid = 0
      ) OR 
      (
        na.realm = 'domain_site' AND na.gid = 0
      ) OR 
      (
        na.realm = 'domain_id' AND na.gid = 0
      ) OR 
      (
        na.realm = 'private_author' AND na.gid = 0
      )
    ) 
  ) AND 
  ( 
    (
      node.type in ('story')
    ) AND 
    (
      node.status <> 0
    ) AND 
    (
      node.language ='de' OR node.language ='' OR node.language IS NULL
    ) 
    AND 
    (
      (
        (
          domain_access.realm = 'domain_id' AND domain_access.gid = 0
        ) OR 
        (
          domain_access.realm = 'domain_site' AND domain_access.gid = 0
        )
      )
    ) 
  )
ayalon’s picture

Dear agentrickard

Thanks for your detailed answer! Before I posted, read a lot in the forum to find an answer for my problem. I observed, that you spend a lot of time and energy for the community by helping / writing patches and so on. I know, that this isn't self-evident and I wanted to thank you personally for your great job you did for the community. I hope that you can get something back too.

Thanks to your detailed explanation I was able to track down the issue. I try to split your hints a bit:

1. Domain Access Advanced
I installed the Domain Access Advanced module. My hope was, that this could solve the problem because it supports multiple node access modules.
But it didn't.

2. Missing distinct
I applied your patch in http://drupal.org/node/284392 (post #122) but there is still no DISTINCT in the query. I'm using the latest views dev version and I think they implemented their own solution. (http://drupal.org/node/501552)

3. Uninstalling private module
It seems that this modules is the source of all my problems. So I decided to uninstall it and rebuild the permissions. But it didn't.

Now I found out another important thing: The duplicates are only on the secondary domain. On the primary domain there are no duplicates. I was not aware of this because I tested on my localhost.

Unfortunatley I'm not able to reproduce this on my local system. I'll try to investigate further.

agentrickard’s picture

Looking at that issue, this seems to be a Views bug.

magpie5212’s picture

Subscribing

agentrickard’s picture

Status: Active » Closed (duplicate)
ayalon’s picture

Status: Closed (duplicate) » Active

Dear all

I'm now quite sure, that this has nothing to do with the DISTINCT core bug.

I have the following situation:
- My drupal installation has 2 domains (2 different sites with shared content)
- The main site is working properly for anonymous users
- The secondary domain has duplicates of nodes in EVERY view if I'm not logged in (anonymous user).
- As soon as I login, I the duplicates are gone.

You will probably agree, that I cannot add a DISTINCT to all queries (mainly 50 views), because this would have a huge performance impact. So the "DISTINCT" core bug would not solve my problem. Because of this I reverted the duplicate status to open.

Is there a way to track down the problem? I'm willing to post SQL queries and debug information. But I down know where to start.

agentrickard’s picture

Status: Active » Closed (duplicate)

No, You are wrong. This is either a core bug or a Views bug.

Node Access queries, by definition, are wrapped in DISTINCT, for all users except user 1 and those with the 'administer nodes' permission. There is a collision between how core fixed the issue and how Views fixed the same issue.

Domain Access is just following the APIs, one of which is broken.

Duplicate. Post your views and query logs in the core issue listed above.

ayalon’s picture

Status: Closed (duplicate) » Fixed

Hi there!

Thanks for your explanation.

Yesterday I spent about 6 hours to find out what is going wrong with the queries.

I created a test environment and I was able to reproduce the duplicates:

- First of all, I installed drupal 6.14
- Then I installed the following modules: views-2.x-dev, domain-2.x-dev, domain-adv, taxonomy_access, private, cck

- Then I created to domains: "localhost" / "workstationname"
- I extended the page content type with some cck fields and made a simple view.

- I added a node, that should display only for domain localhost. Everything worked
- I added a node, that should be private. Worked. The anonymous user did not have duplicates nor was he able to see the private node.

- Then I uninstalled the private module and and selected "Rebuild premission". In from this moment on I had duplicates in all my views for the anonymous use.
- I manually deleted the node_access table and "Rebuild the permission". Duplicates are gone.

- Because I use multiple node_access modules, I activated domain_advanced
- I installed taxonomy_access and reinstalled the private module. Now were 3 node_access modules active
- I made a mix of all different node: some were domain restricted, some restricted by taxonomy, some were private and some were all

- My hope was, that domain_advanced would allow the use of domain, taxonomy_acces and private module
- It did not.. The nodes were displayed accidentally. The node_access table contains different data, if you rebuild the permission and if you save a node afterwards. Sometime one, sometime two or more row for each node were saved in the node access_table.

- Finally I decided to break the golden rule and patched the drupal code
- I applied the multi_node_access_patch for Drupal 6.14 from this thread #579696: multiple_node_access.patch doesn't need update for Drupal 6.16 ?

- I tested again, and had mixed results. If I rebuild the permissions, the result in the node_access table was not the same as if I saved a certain node manually.
- Then I realized that I had to turn on the AND concatenation in an option in the domain-module that is normally HIDDEN. I turned this option on and from then on everything worked perfectly.
- From my point of view, the "AND" mode is the only working mode as soon as the patch is applied. It should not be possible to select the "OR" modus if the patch is applied. The OR modus won't deliver contant results

BUT:
- applying the patch and turning on the "AND" modus resolved all my problems. Nodes with domain, tac and private access restriction were correctly handled for anonymous users.

IMPORTANT:
- always delete all rows in the node_access table and rebuild the permission. In my case, this was the only way out of the duplicate misery.

Status: Fixed » Closed (fixed)

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

colorado’s picture

THANK YOU ayalon - you saved me hours! I was having the same problem, and your solution fixed my problem.

Cheers!!!!!!!

t.lan’s picture

Version: 6.x-2.x-dev » 6.x-2.1

Hi,

thanks for bringing this all together. I had (have) also an issue with duplicate content in views. But its easy to describe as it relates allways to the "Send to all affiliates" tag:
- when content is tagged for "all affiliates" and not for the actual domain it shows up one time
- when the content is tagged for this domain and not for "all affiliates" it also shows up one time
- but when the content ist tagged for this domain AND for all affiliates it shows Twice in the views

I'm not sure that this relates to what is said in this thread.

So some questions and observations:
1) Is my problem the same as here described?
2) Is this behaviour by design?? Is it difficult to make it working like an Or operator (is it "for all affiliates" or "for the actual domain")??
3) With the latest versions of Drupal (6.15) and Views (6.28) both from Dec. 2009 using "Distinct" works without any patch applied (although the referenced patch above is not incorprated). Is the above still valid for my issue AND the moste recent versions?
4) If this is still valid, what is this AND Modus ("...turn on the AND concatenation in an option in the domain-module ..." and where do I find this setting?

Sorry to keep this never ending story alive...

Thomas

kruser’s picture

I just ran into the same problem. I just turned on DISTINCT = yes in all my views and the problem went away.

danieldd’s picture

I'm sorry to post to this closed issue, but just wondering if anyone had found any workable solutions to this that do not have performance issues?

My preference would be to have the option of disabling Node based access altogether (while keeping other elements of Domain Access) unless it is needed, as per this issue- http://drupal.org/node/884294.