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?

CommentFileSizeAuthor
#14 domain_exported_view.txt2.74 KBAnonymous (not verified)
#2 485762-views.patch1.82 KBagentrickard

Comments

agentrickard’s picture

This is a View from the base 'domain' table? Why is it trying to select a node id?

agentrickard’s picture

Status: Active » Needs work
StatusFileSize
new1.82 KB

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?

agentrickard’s picture

Title: 'User Warning' after update » Domain table views try to load NID
nonsie’s picture

Your patch is correct - it should not include nid as an additional field (nid is only available for view type node).

agentrickard’s picture

Category: support » bug
Status: Needs work » Reviewed & tested by the community

@nonsie

You ready to commit this, then?

agentrickard’s picture

Status: Reviewed & tested by the community » Needs review

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?

nonsie’s picture

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 domain 

I'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...

Anonymous’s picture

Patch from #2 worked for me, thanks!

Anonymous’s picture

Status: Needs review » Active

Actually, it seems I now have a related problem...

I'm now getting warnings whenever I clear my cache:

warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/brat/public_html/sites/all/modules/domain/domain_conf/domain_conf.module on line 553.

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.

nonsie’s picture

Status: Active » Postponed (maintainer needs more info)

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?

Anonymous’s picture

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).

agentrickard’s picture

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.

nonsie’s picture

@BWPanda can you attach an export of your view? I'm curious what is going on in there...

Anonymous’s picture

StatusFileSize
new2.74 KB

Exported view attached.

agentrickard’s picture

Status: Postponed (maintainer needs more info) » Fixed

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.

Status: Fixed » Closed (fixed)

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