Using Drupal 5 / HEAD, I cannot use nodereferrer.module. When saving a node which has a nodereferrer field, I get an error message like the following 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 '= 15 ORDER BY n.created DESC' at line 4 query: nodereferrer_referrers SELECT DISTINCT(n.nid), n.vid, n.title FROM node_data_ nr INNER JOIN node n ON n.vid = nr.vid AND n.status = 1 AND n.type IN ('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0') WHERE nr. = 15 ORDER BY n.created DESC in includes/database.mysql.inc on line 167.

I looked at the documentation but I didn't find any "Upgrade your CCK module from 4.7 to 5" page.

in the query, one has nr. = 15 where 15 is the nid, but where $db_info['columns']['nid']['column'] is empty.

    $query = "SELECT       n.nid, n.vid, n.title
              FROM         {" . $db_info['table'] . "} nr
              INNER JOIN   {node} n ON n.vid = nr.vid AND n.status = 1 ". $filter_nodetypes ."
              WHERE        nr." . $db_info['columns']['nid']['column'] . " = %d
              ORDER BY     n.created DESC";
CommentFileSizeAuthor
#4 unset_zero_values_nodereferrer.diff865 bytesbeginner

Comments

beginner’s picture

Status: Active » Closed (duplicate)
beginner’s picture

Status: Closed (duplicate) » Active

Hmmm, no.
This error is coming back despite the upgrade patch mentioned... I am looking into it...

beginner’s picture

The problem is related to the fact that the fields that are not supposed to be set, are actually attributed the value 0.

Thus, instead of having something like:

Array
(
    [field_1] => field_1
)

we get something like this:

Array
(
    [field_1] => field_1
    [field_2] => 0
    [field_3 => 0
)

I am not familiar with the cck API, so I am not sure if it's a problem with this module, or a problem with content.module.

beginner’s picture

Title: SQL error » SQL error caused by passed array with values = 0.
Priority: Critical » Normal
Status: Active » Needs review
StatusFileSize
new865 bytes

The solution is to check for zero values and unset them.

It may be a content.module bug, but I only found a solution within nodereferrer.
It may not be the best fix, but it works for now. The problem is that i don't know enough of the CCK API.

beginner’s picture

I filed this report against content.module:
http://drupal.org/node/107658

beginner’s picture

Assigned: Unassigned » beginner
dopry’s picture

Status: Needs review » Fixed

tnx, committed with #139293 v1.5.

Anonymous’s picture

Status: Fixed » Closed (fixed)