Domain table views try to load NID

BWPanda - June 9, 2009 - 00:19
Project:Domain Access
Version:6.x-2.0-rc7
Component:- Domain Views
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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

agentrickard - June 9, 2009 - 14:04

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

#2

agentrickard - June 9, 2009 - 16:23
Status:active» needs work

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?

AttachmentSize
485762-views.patch 1.82 KB

#3

agentrickard - June 9, 2009 - 16:24
Title:'User Warning' after update» Domain table views try to load NID

#4

nonsie - June 9, 2009 - 17:47

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

#5

agentrickard - June 9, 2009 - 19:44
Category:support request» bug report
Status:needs work» reviewed & tested by the community

@nonsie

You ready to commit this, then?

#6

agentrickard - June 9, 2009 - 21:57
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?

#7

nonsie - June 10, 2009 - 00:44

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

#8

BWPanda - June 10, 2009 - 23:26

Patch from #2 worked for me, thanks!

#9

BWPanda - June 11, 2009 - 00:08
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.

#10

nonsie - June 11, 2009 - 00:14
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?

#11

BWPanda - June 11, 2009 - 00:26

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

agentrickard - June 11, 2009 - 13:52

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

nonsie - June 11, 2009 - 16:03

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

#14

BWPanda - June 11, 2009 - 23:04

Exported view attached.

AttachmentSize
domain_exported_view.txt 2.74 KB

#15

agentrickard - June 14, 2009 - 20:12
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.

#16

System Message - June 28, 2009 - 20:20
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.