I use Domain Access to have a staging area for content before putting it live. My domain structure is as follows:
mydomain.com
staging.mydomain.com
subdomain.mydomain.com
staging.subdomain.mydomain.com
The staging domains are inactive, and are used to initially publish content to, from which it is later published to the main domains which are active.
When using the core search functionality, the search results return nodes that are in the inactive domains as well as the active domains. I'm searching with an anonymous user, who does not have permissions to access inactive domains. After clicking on the link of a search result of a node in an inactive staging domain, I get the "Access Denied" error as expected.
I am using the "Search all domains from any URL" advanced setting so I can search across all of my domains. If I change this to "Search content for the current domain only" it only shows results from the live domain I'm searching from, and no where else. Unfortunately, I'd like searches to reach across both of my active domains, but not the inactive domains (for those without appropriate permissions).
It would be great if there was another advanced setting regarding searching domains - something along the lines of a checkbox "Do not search inactive domains". Or maybe enabling the searching of node content on a domain by domain basis. Even only allowing users with the "Access inactive domains" permission to see the results of inactive domains in the search would suffice.
Thanks
K.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 1362352-domain-search-broken.patch | 2.12 KB | agentrickard |
Comments
Comment #1
agentrickardYou can prevent this right now by selecting "Search content for the current domain only" from the settings page. If you are user 1 or can 'bypass node access', you may need to "Restrict node views for administrators" as well.
I agree, however, that we should filter these out.
Comment #2
agentrickardIn the 3.x branch, searching across all domains seems to be broken altogether.
Comment #3
agentrickardI suspect that you only see search results because you are an administrator.
The attached patch "works", but cannot be committed, because if you have > 50 domains or so, the node access query will utterly break.
So the options seem to be:
The problem, for reference, is in SeachQuery::executeFirstPass
Returns no results.
In Drupal 6, this didn't happen.
The problem appears to be that node_access_view_all_nodes() is behaving differently in D7.
Comment #4
agentrickardThe problem seems to be in search.module.
It seems that search $query->executeFirstPass() ALWAYS filters for node access, even if node_access_view_all_nodes() returns TRUE
Comment #5
agentrickardIt seems that search $query->executeFirstPass() ALWAYS filters for node access, even if node_access_view_all_nodes() returns TRUE
Comment #6
agentrickardFiled as core issue #1382292: Search module applies node access query filters even if user can view all nodes
Comment #7
agentrickardAnd that core issue is bogus. This was entirely self inflicted. See #1396800: Special Page Requests not working
Comment #8
banoodle commentedThank you, agentrickard for working on this issue.
I had the latest 7.x stable release of Domain Access installed and encountered this problem (search is not being restricted by domain even though it's enabled in advanced settings).
So I upgraded to the latest Dev release and applied the above patch. It didn't hurt anything, but it didn't solve my issue.
I'm just using core drupal search right now: do I maybe need to reindex the site for this to work? Or maybe I need to install Search API?
Any advice greatly appreciated. If I can't get this approach to work, I'm contemplating trying this recipe:
http://www.metaltoad.com/blog/drupal-solr-search-domain-access-filtering
Anne
Comment #9
agentrickardFirst, make sure you aren't testing as an administrator (user 1) or someone with the 'Bypass node access' permission.
Comment #10
banoodle commentedYeah -- I'm definitely not authenticated when I'm testing this (though I have been known to make this mistake ; )
Comment #11
kenorb commentedComment #12
bluegeek9 commentedDrupal 7 in End of Life and no longer supported. We encourage you to upgrade to a supported version of Drupal. For more information, see https://www.drupal.org/upgrade.