Closed (duplicate)
Project:
Node import
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
15 Sep 2008 at 13:15 UTC
Updated:
18 Oct 2008 at 08:43 UTC
I discovered a bug when importing a nodereference that didn't had a value set, or the value was zero. Node import would look for a title, and if having a node's title blank it would wrongly output that node's id.
this piece of code in supported/cck/content.inc line 126
case 'nodereference':
// If $value is numeric use it
if (intval($value) > 0) {
$value = intval($value);
} // otherwise find a node title that matches and get nid.
else {
$referenced_nodes = array();
$sql = "SELECT nid, title FROM {node} WHERE title SOUNDS LIKE '%s'";
$result = db_query($sql, $value);
$record_found = db_fetch_object($result);
if ($record_found) {
$value = $record_found->nid;
}
}
break;
should be changed to something like this:
case 'nodereference':
// If $value is numeric use it
if (intval($value) > 0) {
$value = intval($value);
} // otherwise find a node title that matches and get nid.
else if ( $value != '' && $value != 0 ) {
$referenced_nodes = array();
$sql = "SELECT nid, title FROM {node} WHERE title SOUNDS LIKE '%s'";
$result = db_query($sql, $value);
$record_found = db_fetch_object($result);
if ($record_found) {
$value = $record_found->nid;
}
}
break;
Comments
Comment #1
Robrecht Jacques commentedCorrect. This has been fixed already. Eg try 5.x-1.7 or 5.x-1.8 which will be released later this weekend.
Setting it to duplicate.