My use case is similar to the "Domain Access: Available on current domain" filter, except that I want to specify the domains to retrieve content from rather than just the current domain.

So, I've set up filters as

Content: Published (Yes)
AND
Domain Access: Access Type (= All affilates (domain_site))  OR
Domain Access: Domain ID (exposed) 

When a domain id is not specified the condition is excluded, and things work as expected (only "All affiliates" content is included)
However, when a domain id is specified, the "All affiliates" content is excluded, and only content with that domain id specified is shown.

The issue is due to how the condition is added in domain_views_handler_filter_domain_access_gid. Since realm = 'domain_id' is statically added to option group 0, the resulting sql is:

node.status = '1'
AND 
domain_access.realm = 'domain_id'
AND ( 
  domain_access.realm IN  ('domain_site') /* this will never be true */
  OR 
  domain_access.gid IN ('126')
)

and the query needs to be like:

node.status = '1'
AND ( 
  domain_access.realm IN  ('domain_site')
  OR (
    domain_access.gid IN ('126')
    AND 
    domain_access.realm = 'domain_id'
  )
)
CommentFileSizeAuthor
#1 domain_views-2238287-1.patch1.57 KBgapple
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gapple’s picture

Status: Active » Needs review
FileSize
1.57 KB

The attached patch, rather than adding the where condition in an overridden query() method, adds it via a DatabaseCondition object within overridden op_simple() and op_empty() methods.

In the use case I provided, using both the "Access Type" and "Domain ID" filters, there will be duplicate results if an item has both the "all affiliates" checkbox and the requested domain id selected and requires that the query be made DISTINCT.