I'm playing with the tagnode module on a test site. It seems to be working fine, but if I go to admin/settings/tagnode, I get the following errors at the top of the page:

user error: 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 'exists(select tid from term_data t where t.name = n.title)' at 
query: select nid, title, type from node n where status=1 and type in ('flexinode-1') and not exists(select tid from term_data t where t.name = n.title) in /home/shavnyak/public_html/test/includes/database.mysql.inc on line 66.
user error: 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 'exists(select n.nid from node n where n.status=1 and n.title = 
query: select t.tid, t.name, t.vid from term_data t where t.vid in (2) and not exists(select n.nid from node n where n.status=1 and n.title = t.name) in /home/shavnyak/public_html/test/includes/database.mysql.inc on line 66.

My site is Drupal 4.6 on a Linux server, kernel 2.4.28, Apache 1.3.33, PHP 4.3.11, and MySQL 4.0.24

Comments

dado’s picture

Shaven,
Yes, I was using SQL syntax that does not work w/ MySQL 4.0x

I fixed and committed to CVS. You can get the latest tagnode.module at

http://cvs.drupal.org/viewcvs/drupal/contributions/modules/tagnode/

Please let me know thether this works.
Thanks,
Dado

dado’s picture

Status: Active » Fixed

I received word from jasonwhat that this bug fix worked.

ShavenYak’s picture

Looks good to me now. Thanks!

samwilson’s picture

Status: Fixed » Active

I am also getting this error, and I have tried both module files from CVS to no avail. I'm trying to figure it out now... I'll post what I come up with.

samwilson’s picture

Status: Active » Fixed

Okay, I've figured something out:

In _maintain_tagnodes and from line 855 there is the following:

   // *************** ORPAHNED TAGNODE NODE FIX/DELETE FORM *********************
   $page .= "<h2>".t("Orphaned Nodes")."</h2>";
   $tagnode_types = _utility_tagnode_array_to_qualified_string(_get_tagnode_types());
      		
   	$sql = "select n.nid, n.title, n.type from {node} n LEFT JOIN {term_data} t ON n.title = t.name " .
   		"where n.status=1 and n.type in ($tagnode_types) and t.name is NULL";

The problem I had was that I didn't have any tagnode types, so the WHERE clause was reading WHERE n.status=1 and n.type in () and t.name is NULL, which clearly is invalid. My solution is to build that part of the WHERE clause that applies to tagnode_types beforehand, as show below.

   // *************** ORPAHNED TAGNODE NODE FIX/DELETE FORM *********************
   $page .= "<h2>".t("Orphaned Nodes")."</h2>";
   $tagnode_types = _utility_tagnode_array_to_qualified_string(_get_tagnode_types());
   if ($tagnode_types != '') $tagnode_types = "and n.type in (".$tagnode_types.")";
   	$sql = "select n.nid, n.title, n.type from {node} n LEFT JOIN {term_data} t ON n.title = t.name " .
   		"where n.status=1 $tagnode_types and t.name is NULL";

Also, a similar situation was occuring around line 900, which I solved with a similar patch:

   // *************** ORPAHNED TAGNODE TERMS DELETE FORM *********************
   $page .= "<h2>".t("Orphaned Terms")."</h2>";
   $tagnode_vocabs = _utility_tagnode_array_to_qualified_string(_get_tagnode_vids(),",","");
   if ($tagnode_vocabs != '') $tagnode_vocabs = "t.vid in ($tagnode_vocabs) and ";
      
   $sql = "select t.tid, t.name, t.vid from {term_data} t LEFT JOIN {node} n ON t.name = n.title " .
   		"where $tagnode_vocabs n.title is NULL";
dado’s picture

Status: Fixed » Active

samwilson,
Outstanding work! Many thanks. I will incorporate your fixes ASAP (next ~day). Also adding 1 or 2 other changes courtesy of gondalo.
dado

nethome’s picture

Version: master » 4.6.x-1.x-dev

Same problem occurs in my setup (4.6) but the patch suggested here does not solve the problem. The error message that I get is following:

ON n.title = t.name where n.status=1 and n.type in () and t.name is NULL in /home/nethome/public_html/powerliving/includes/database.mysql.inc on line 66.
user error: 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 n.title is NULL' at line 1
query: select t.tid, t.name, t.vid from term_data t LEFT JOIN node n ON t.name = n.title where t.vid in () and n.title is NULL in /home/nethome/public_html/powerliving/includes/database.mysql.inc on line 66.

dado’s picture

I changed samwilson 's fix slightly. I find no error currently. Committed to CVS, DRUPAL-4-6 branch. Please let me know if this fixes. Will commit these fixes to HEAD version also if all is well.

Thanks!
Dado

dkruglyak’s picture

Priority: Normal » Critical

i tried the latest fix from DRUPAL-4-6, running on PHP 5 / Linux. Here are the errors i get:

=== [Case 1] No node types are defined as tagnodes ===

A) Opening tagnode maintenance gives this error

warning: Invalid argument supplied for foreach() in /var/www/drupal/modules/tagnode/tagnode.module on line 1047.

warning: Invalid argument supplied for foreach() in /var/www/drupal/modules/tagnode/tagnode.module on line 1047.

B) Opening create content on any node type gives this error

warning: Invalid argument supplied for foreach() in /var/www/drupal/modules/tagnode/tagnode.module on line 535.

warning: Invalid argument supplied for foreach() in /var/www/drupal/modules/tagnode/tagnode.module on line 535.

=== [Case 2] Some node types are defined as tagnodes ===

A) Opening tagnode maintenance works fine
B) Opening create content on any node type gives this error

warning: sprintf() [function.sprintf]: Too few arguments in /var/www/drupal/includes/database.inc on line 154.

user error: Query was empty
query: in /var/www/drupal/includes/database.mysql.inc on line 66.

dkruglyak’s picture

... and here is what shows up on front page, per previoius example:


warning: sprintf() [function.sprintf]: Too few arguments in /var/www/drupal/includes/database.inc on line 154.
user error: Query was empty
query: in /var/www/drupal/includes/database.mysql.inc on line 66.
dado’s picture

dkruglyak,

Thanks for the bug reports. I am unable to reproduce in my PHP4 environment. I wonder if this is an issue on PHP5 only. If you have any inspiration to investigate fixing please don't hesitate to contact me w/ questions/ideas (either posing here or contact me directly). I will pursue at my end by trying to figure out the bug & perhaps running attempted fixes by you. Many thanks,

dado

dado’s picture

Assigned: Unassigned » dado

OK, I committed changes to CVS (DRUPAL-4-6 branch). I hope & expect these to resolve some of the problems highlighted by dkruglyak. I believe these bugs are apparent when running tagnode on Drupal 4.6 and PHP 5.

Particularly, I believe the changes might fix the bugs which occur when no tagnodes have been defined.

I do not have a PHP 5 environment to test, so I would be grateful for any feedback as to whether current version (for Drupal 4.6) is working. Thanks,
Dado

dado’s picture

I got a PHP5 dev environment and was able to fix a number of bugs on PHP5. Now the module seems to work on PHP4 & PHP5 without any errors I am aware of.

dado’s picture

Status: Active » Fixed

no reply. i assume the fixes worked.

dries’s picture

Status: Fixed » Closed (fixed)