Hi,
I'm having an issue getting the "Available on current domain" filter to show nodes that are checked as 'Send to all affiliates' to show within a view that being accessed on a sub domain other than the domain the node is assigned to.
Here is the SQL generated by a view I'm using to try and figure out the issue...
SELECT node.created AS node_created, node.nid AS nid
FROM node node
LEFT JOIN domain_access domain_access ON node.nid = domain_access.nid AND domain_access.realm = 'domain_id'
WHERE (( (node.status = '1') AND (node.type IN ('offer')) AND (((domain_access.realm = 'domain_id' AND domain_access.gid = 5) OR (domain_access.realm = 'domain_site' AND domain_access.gid = 0))) ))
ORDER BY node_created DESC
LIMIT 10 OFFSET 0
Could this be related to the domain_access join not including domain_access.realm = 'domain_site' records? When I alter the SQL to include these records it seems to work.
Comments
Comment #1
agentrickardYes. That JOIN is incorrect and needs to be removed. I wonder why it's there.
Comment #2
sepph commentedI've commented out the following lines 125 > 127 in domain_views.views.inc and it seems to work fine now.
It looks as though this 'extra' item was added during the last release as version 7.x-1.3 doesn't have this. It looks as though this might have been added as a fix for this issue - http://drupal.org/node/1207936 - as the thread contains a patch adding in these lines (http://drupal.org/files/issues/1207936-bad-join.patch).
Comment #3
agentrickardRight, so there was some required logic for one use-case but not the other. Needs some review.
Thanks for the work on this.
Comment #4
agentrickardI think I tracked it down and fixed this in #1090618: PDOException: using domain editor id as argument in views 3.
Comment #6
Xomby commented@agentrickard - that didn't seem to fix the issue.
Your patches, which yield the following view sql:
which looks like it should work properly... however even running this manually through phpmyadmin is coming up with the same results I'm seeing in the view, just two articles instead of 12 (for me anyway).
The section: "AND domain_access.realm = 'domain_id'" right there in the left join is filtering out all of the "all affiliates" content before we can look for them.
By commenting out lines 125-127 of domain_views.views.inc resolves the issue
The issue with doing this, however, is it returns duplicate rows.
The fix for THAT is already built into views.
Under the advanced drop down in your view, select query settings, and then distinct.
voila... problem solved...
Comment #7
Xomby commentedComment #8
agentrickardSo, what are you suggesting we do?
Comment #9
Xomby commentedWell... There's a few options:
Comment #10
broeker commentedThis one was driving me mad -- updated dev versions of Views, Domain, Domain Views, etc. and none of my Views filters were respecting the Domain Access: Available on current domain - All Affiliates setting. Even if a node was set to show on All Affiliates, it would only show up in the view if it was explicitly set in the "Publish to:" options.
I can confirm that fix above (commenting out those three lines) fixed my problem.
My bigger question is if this is normal, or if I've got something going on to prevent this from working as it should. This seems like a significant issue but there are very few other cases out there regarding this problem.
Comment #11
agentrickardRight. We have to figure out how the two patches -- this one and #1207936: Views domain id no show -- interact.
Comment #12
Yuri commentedThis issue is till not resolved in the latest dev.
By the way, those lines of #2 are now 194-196
Comment #13
Yuri commentedand solution #2 does not work any more (in my case)
Comment #14
agentrickardAttaching a copy of your View would be helpful.
Comment #15
fox mulder commentedHi everybody!
Here is the export of my view (domain_views.views.inc is original, not patched).
As Yuri wrote in #13 commenting out of lines 194-196 doesn't influence [UPDATE: see #16] the SQL query of view in 7.x-1.x-dev version.
Comment #16
fox mulder commentedCommenting out those certain lines works, but the correct line numbers are: 177-179 in $data['domain_access']['table']['join']['node'] array and than it should be clear all cache.
Comment #17
peacog commentedCommenting out those line works for me too, and I don't get any duplicates, so maybe this is ready to commit? I've rolled a patch against the current dev.
Comment #18
ericclaeren commentedThe lines removing is one thing, I found out that the field (assigned to current domain) uses a boolean handler, this won't work because when it's from the domain_site realm the gid is 0, which is false, while domain_access says it's true.
So I have created a patch which adds an additional handler and removed the 3 lines, everything seems to work fine. Maybe the maintainer can look into to this problem.
There's another issue http://drupal.org/node/1207936 with this patch (http://drupal.org/files/1090618-query.patch). Don't know if the 3 extra lines are added on purpose, if they are needed for another field/filter then the solution below might be an option, but since I don't know if it's necessary, I'm not adding them.
I have created a new patch including the field handler for this issue. Could the maintainer look into this, it would be great is this is solved in the latest release since it's quite a large bug for this module, thanks!
Comment #19
ericclaeren commentedCrap I applied the wrong comment number, let's try this again.
Comment #20
ericclaeren commentedSorry, I misunderstood something, removing the domain_id line creates duplicates. I am trying to create a fix for it.
* Edit: You have to use distinct, in your query settings.
Comment #21
agentrickardI think it was trying to fix that duplicates issue that caused this problem in the first place.
Comment #22
ericclaeren commentedThe fix is adding a group by on the query in the filter handler, but I found a weird problem, that you also need to add a having statement otherwise the group by (add_groupby) was not added to the query in views and when adding a having statement triggers other group by's are also activated.
Hard to explain this :) Does this sound familiar or made any sense?
Comment #23
alexanderpas commentedPossibly related: #577008: "Domain Access: Available on current domain True" does not show results if not individually checked on node
Comment #24
bibo commentedI agree, this issue and #577008: "Domain Access: Available on current domain True" does not show results if not individually checked on node both seem to address the same problem (which IMO is pretty critical from this modules standpoint).
I believe patch in #19 would address both issues, havent tested yet.
Comment #25
bibo commented#19 worked great, thank you! Please commit.
Comment #26
2pha#19 worked for me too.
Comment #27
fonant commented#19 works here, in that nodes published to all domains are included. However it does result in duplicate results (presumably nodes that are published to all domains and to the current domain) but that can be fixed by the view's query settings.
Comment #28
rosberg commentedpatch from #19 works, thank you very much!
Comment #29
knalstaaf commentedRTBC I Guess, but what about the file domain_views_handler_field_domain_access_current_all.inc that should go in the includes folder on the Drupal root (#19)?
Is that file still necessary?
Comment #30
mautumn commentedPatch from #19 works, thank you very much!
Comment #31
4kant commented#19 + the tipp from #27 helped me.
Thanks