Hi all,

I keep getting this error message:

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 'AND realm = 'domain_id')) AND grant_view >= 1' at line 1 query: SELECT COUNT(*) FROM drpl_node_access WHERE (nid = 0 OR nid = 708) AND ((gid = 0 AND realm = 'all') OR (gid = AND realm = 'domain_id')) AND grant_view >= 1 in /home/......../php/drupal/modules/node/node.module on line 2049.
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 'AND realm = 'domain_id')) AND grant_view >= 1' at line 1 query: SELECT COUNT(*) FROM drpl_node_access WHERE (nid = 0 OR nid = 708) AND ((gid = 0 AND realm = 'all') OR (gid = AND realm = 'domain_id')) AND grant_view >= 1 in /home/......./php/drupal/modules/node/node.module on line 2049

Is this a bug?

Cheers,
DrupalFan

CommentFileSizeAuthor
#18 477290-docs.patch8.58 KBagentrickard

Comments

agentrickard’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

It looks like the Domain Access module is either:

a) not installed correctly
b) running on a misconfigured host

The problem area is this:

OR (gid = AND realm = 'domain_id'))

gid should never be passing _no value_ here. This suggests to me that the $_domain global is not being set correctly.

Other than that, there is not enough information here to offer any help.

eldrupal’s picture

Thank you for pointing out the error in the SQL. The bug is invoked only upon creating a new article, right after submission. I have started seeing this error sporadically after I have activated domain_source. The installation does not seem to be malfunctioning.

alex.cunha’s picture

I got this warning on the admin interface:

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 '))) AND ( b.theme = 'rootcandy' AND b.status = 1 AND (r.rid IN (2) OR r.rid IS ' at line 1 query: SELECT DISTINCT b.* FROM blocks b LEFT JOIN blocks_roles r ON b.module = r.module AND b.delta = r.delta INNER JOIN domain_blocks db ON db.module = b.module WHERE ( db.delta = b.delta AND ((db.realm = 'domain_site' AND db.domain_id = 0) OR (db.realm = 'domain_id' AND db.domain_id = ))) AND ( b.theme = 'rootcandy' AND b.status = 1 AND (r.rid IN (2) OR r.rid IS NULL) )ORDER BY b.region, b.weight, b.module in /home/.../public_html/d6/modules/block/block.module on line 407.

On the user (site front end for anonymous users) the list of warnings is bigger.

Just after enabled modules:
Domain Access 6.x-2.0-rc8
Domain Configuration 6.x-2.0-rc8
Domain Content 6.x-2.0-rc8
Domain Navigation 6.x-2.0-rc8
Domain Theme 6.x-2.0-rc8

Drupal 6.12
MySQL 5.1.30
PHP 5.2.8

agentrickard’s picture

No, you have Domain Blocks installed as well. This is either a Domain Blocks bug, or you have the same configuration problem as listed above.

"the list of warnings is bigger" is useless information. Either be detailed or don't report.

nonsie’s picture

Being a maintainer of Domain Blocks all I can say is something is not right with your Domain Access install. For some reason you're missing domain_id in your query. Did you by any chance alter domain IDs in the db?

agentrickard’s picture

Version: 6.x-2.0-rc6 » 6.x-2.0-rc8

I wonder if this is the ghost bug of domain 0 disappearing from the db?

avpaderno’s picture

Title: SQL Bug in node.module?? » Possible SQL bug
agentrickard’s picture

Title: Possible SQL bug » Missing $_domain['domain_id'] throws SQL error

This is NOT a SQL bug. It is a processing error caused by either a) bad site configuration or b) a missing database row.

The question is: Why is $GLOBALS[$_domain]['domain_id'] not populated correctly?

We cannot replicate because we are not affected by a) or b), and no one can reliably report the cause.

alex.cunha’s picture

I have restored the database to the point before the domain access install and I will try again today using a testing environment and giving more detailed information.
If you can suggest ideas to debug better I will follow your instruction.
Thanks.

agentrickard’s picture

After you re-install, make sure that the {domain} table contains a row 0. This is your default domain.

Otherwise, you should get error messages (clearly marked as Domain Access errors, not database query errors) if the module is not installed correctly.

alex.cunha’s picture

Ok, have restored the database and I'm using a sub-domain as a test environment.

Just enabled one module: Domain Access 6.x-2.0-rc8.

After module activation, the modules list shows this:

# Domain access failed to load during phase: -1. Please check your settings.php file and site configuration.
# 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 'AND realm = 'domain_id')) AND grant_view >= 1' at line 1 query: SELECT COUNT(*) FROM node_access WHERE nid = 0 AND ((gid = 0 AND realm = 'all') OR (gid = AND realm = 'domain_id')) AND grant_view >= 1 in /home/user/public_html/d6/modules/node/node.module on line 2161.

My settings.php just points to the database. Is required any change on the settings.php? Looking into the manual, seems there are not.

Looking into the database seems I have at least 3 new tables:
domain has 1 record
domain_access has 114 records
domain_editor has 128 records
Also node_access was updated.

Table contents:

node access before install Domain_access

nid 	gid 	realm 	grant_view 	grant_update 	grant_delete
0  	0  	all  	1  	0  	0

node access after install Domain_access

nid 	gid 	realm 	grant_view 	grant_update 	grant_delete
0 	0 	all 	1 	0 	0
0 	0 	domain_all 	1 	0 	0

SELECT * FROM `domain`

0 multi.domain.com domain.com http 1

The content of this tables, looks strange:

SELECT * FROM `domain_access` LIMIT 0 , 30

1  	0  	domain_id
1 	0 	domain_site
2 	0 	domain_id
2 	0 	domain_site
3 	0 	domain_id
3 	0 	domain_site
4 	0 	domain_id
4 	0 	domain_site
5 	0 	domain_id
5 	0 	domain_site
6 	0 	domain_id
6 	0 	domain_site
7 	0 	domain_id
7 	0 	domain_site
8 	0 	domain_id
8 	0 	domain_site
9 	0 	domain_id
9 	0 	domain_site
10 	0 	domain_id
10 	0 	domain_site
11 	0 	domain_id
11 	0 	domain_site
12 	0 	domain_id
12 	0 	domain_site
13 	0 	domain_id
13 	0 	domain_site
53 	0 	domain_id
53 	0 	domain_site
54 	0 	domain_id
54 	0 	domain_site

SELECT * FROM `domain_editor` LIMIT 0 , 10

1  	0
2 	0
3 	0
4 	0
5 	0
6 	0
7 	0
8 	0
9 	0
10 	0

Why these tables are populated this way?

If necessary more info, please ask.

By the way, the link to docs is not available (http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/domain/READ...)

alex.cunha’s picture

ok, the problem describe before was gone after I add this line
include './sites/all/modules/domain/settings.inc';
into the settings.php

May I suggest add to the docs (linked at the module drupal.org frontpage) a reference to the INSTALL_QUICKSTART.txt?
I missed this important step!

thanks

agentrickard’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

No. This is clearly documented now. If you don't read the provided docs, that is user error.

The quickstart is for people too "busy" to read the full INSTALL.txt.

We should probably clarify section 2 of README.txt.

agentrickard’s picture

Status: Closed (fixed) » Active
agentrickard’s picture

Title: Missing $_domain['domain_id'] throws SQL error » Add documentation note about settings.php to README
Category: support » task
eldrupal’s picture

Status: Active » Fixed

@agentrickard: indeed, a missing database row (row 0 in the domain table) was the cause of the problem. Thank you for identifying it.

agentrickard’s picture

Status: Fixed » Active

This is still a documentation task.

@DrupalFan

The question is -> Why was there a missing database row? Did you not run the upgrade?

agentrickard’s picture

Status: Active » Fixed
StatusFileSize
new8.58 KB

Cleaned up the README a bit and added some more helpful text in two places of the UI.

Status: Fixed » Closed (fixed)

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