Domain table views try to load NID
| Project: | Domain Access |
| Version: | 6.x-2.0-rc7 |
| Component: | - Domain Views |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Just upgraded to DA 6.x-2.0-rc7 and am seeing the following User Warning:
user warning: Unknown column 'nid' in 'field list' query: SELECT domain.domain_id AS domain_id, domain.subdomain AS domain_subdomain, domain.sitename AS domain_sitename, nid FROM domain domain WHERE domain.valid <> 0 ORDER BY domain_sitename ASC in /home/brat/public_html/sites/all/modules/views/includes/view.inc on line 735.
I have a view that lists (or used to list) my domains and link to each one, however that's no longer appearing so I'm thinking that's the problem... I have subdomain and sitename fields in that view, but didn't have a domain_id field, so I added a domain_id field but that didn't seem to do anything...
I also have an overridden views temple file for this view, but I don't think it's even getting to that stage as I've added dsm($row) which isn't displaying anything.
Any ideas?

#1
This is a View from the base 'domain' table? Why is it trying to select a node id?
#2
This is a temporary patch. I suspect we are trying to use the same field handler for different reasons. We cannot load NID on straight domain views.
nonsie?
#3
#4
Your patch is correct - it should not include nid as an additional field (nid is only available for view type node).
#5
@nonsie
You ready to commit this, then?
#6
Actually, I'm not sure.
It looks to me like that code is in there for use when gathering data from the {domain_access} table. So I think this needs work. AFAIK, we should be do this when dealing with node data, but not if the base table is {domain}.
Yes?
#7
I ran a simple test after applying the patch and created two views - one using view type domains and one view type node. These are the only view types that allow domain fields (view type user uses domain_editor table). Both views pull out 3 fields - domain id, sitename and subdomain
Here's the query created by view type = node
SELECT node.nid AS nid, domain.domain_id AS domain_domain_id, domain.sitename AS domain_sitename, domain.subdomain AS domain_subdomain, node.nid AS node_nid FROM node node LEFT JOIN domain_access domain_access ON node.nid = domain_access.nid INNER JOIN domain domain ON domain_access.gid = domain.domain_id AND (domain_access.realm = 'domain_id')view type = domain creates the following query:
SELECT domain.domain_id AS domain_id, domain.sitename AS domain_sitename, domain.subdomain AS domain_subdomain FROM domain domainI'm pretty sure removing nid does no harm - but it has been a long day and I might remember something overnight that will break if we remove it...
#8
Patch from #2 worked for me, thanks!
#9
Actually, it seems I now have a related problem...
I'm now getting warnings whenever I clear my cache:
I think the culprit code is what I'm using for my domain view in the overriden views template file:
<?php
/**
* Add slogan to each domain
*/
?>
<?php dsm($row); ?>
<a href="http://<?php print $row->domain_subdomain; ?>"><?php print $row->domain_sitename; ?></a>
<br />
<?php
if ($row->domain_id != 0) {
print domain_conf_variable_get($row->domain_id, 'site_slogan');
} else {
print variable_get('site_slogan', '');
}
?>
From the documentation in domain_conf.module, the first argument is the domain ID, not an array, so I don't see what the problem is...
I don't know exactly what the above patch does, but since I only started experiencing this issue since applying the patch, I'm thinking it's related.
#10
Does the error go away when you comment out this code in views template file? If so, what's in $row->domain_id once you print it out?
#11
Yes, removing the code removes the errors.
Adding
dsm($row->domain_id);to the end of the file prints out each of my domain IDs (i.e. 0, 5, 2, 7, 4, 6, 1).#12
This is what I mean by the handler being used for more than one use-case. I think that some of the Views that get built want to use the extra fields and some do not.
#13
@BWPanda can you attach an export of your view? I'm curious what is going on in there...
#14
Exported view attached.
#15
My mistake. BWPanda's issue is unrelated to this bug.
@BWPanda -- your issue is already at #469856: Display site slogan in view?.
Committing #2 to HEAD.
#16
Automatically closed -- issue fixed for 2 weeks with no activity.