Project:Visitor Info
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:twooten
Status:closed (fixed)

Issue Summary

When calling Visitors Location Map with admin/reports/visitorinfo I am getting a red error message like that one ....

"user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (n.language ='en' OR n.language ='' OR n.language IS NULL) LIMIT 0, 200' at line 1 query: SELECT * FROM visitorinfo order by csid desc WHERE (n.language ='en' OR n.language ='' OR n.language IS NULL) LIMIT 0, 200 in /home/jadajadajada/public_html/blablabla/sites/all/modules/visitorinfo/visitorinfo.module on line 75."

with the Visitors Location Map just underneath that read error message, but the map does not show a single visitor location .... and never changes this "Last 1 visitor locations." note just above the global map.

visitors are arriving at the site so that is not the problem ...

Comments

#1

Assigned to:Anonymous» twooten
Status:active» needs review

I believe that is due to my use (mis-use is probably more accurate), of the db_rewrite_sql() function. From what I have been able to determine, it is supposed to be used in circumstances such as when you are doing a node listing, when other conditions need to be tested as well. For instance, the node module modifies queries for node listings to filter nodes protected by access fields. So basically what that means is that you would use db_rewrite_sql() if you were producing a listing of nodes but some of those nodes should only be shown to certain users. db_rewrite_sql()'s usage would ensure that those access rules were observed.

I believe the particular error above is due to calling db_rewrite_sql() with the wrong number of arguments. Those arguments are apparently needed when certain other modules are actually performing a rewrite of the sql. But as I think about it, I realize that I do not need to use that function, a simple db_query_range() would work just fine. The documentation for the database abstraction layer says regarding db_rewrite_sql() 'Use it for listing queries'. That's not what I am doing. db_query_range() is better suited since it 'runs a limited-range query in the active database'.

I was able to recreate an error very similar on another site. Applying this patch seemed to clear up the problem.

AttachmentSize
visitorinfo-issue#668042.patch 776 bytes

#2

is it just me post-christmas-drunk to experience this patch as weird, as a link to drupal-main-site ?

or is there a textfile behind this patch-link or not ?

thanks for your attempt anyway ....

#3

Awesome... I uploaded a .patch file. Let's try again with a .zip

Ok, nope that didn't work either. Something I should know about uploading files here?

Tim

AttachmentSize
visitorinfo-issue#668042.patch.zip 571 bytes

#4

Weird ... but there is no rush !

#5

AttachmentSize
visitorinfo-issue-668042.patch.zip 571 bytes

#6

there we go. It was the '#' in the name. I should have known.

#7

will check file later on ... managed to d-load it now !

thank you !

#8

oh ... it made a biiiiiig difference. on a first glance your patch did the trick and things seem to work the way they are supposed to work !

thank you !

#9

I think actually you just need to use capital letters with your SQL commands (order by csid desc vs ORDER BY csid DESC). But yes, you should not be using db_rewrite_sql() unless you know that it's a query that should be using it (like on nodes, taxonomy terms, etc).

#10

Status:needs review» fixed

#11

Status:fixed» closed (fixed)