deleted fields in my nodes
hsfdrupal - December 23, 2007 - 03:22
| Project: | Comment CCK |
| Version: | 5.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I installed this module, altered my existing CCK type to allow comments to modify,
commented on several of my nodes and modified vaklues. Three things:
1. 2 of my fields, both node references, were now null.
2. Another field, a matrix, was wiped out of all values
3. When viewing the node, the comment displayed the => symbol but with nothing on either side of it, ie, it wasn't showing old/new values.
Good luck, I am not touching this module since it doesn't seem ready for prime time. How much testing was done?

#1
Not a programer just wanted to learn about how it can happen.
So this module deletes any field with CCK node-reference?
#2
Trying to sort it out now
but it looks like essentially the way 'insert' operation occurs the $node it is dealing with is the wrong structure for the cck node field data to stick
function comment_cck_comment(&$comment, $op) {switch ($op) {
case 'insert':
// Merge the new array with the old node
$node = (object) array_merge((array) node_load($comment['nid']), $comment['comment_cck']);
$previous_vid = $node->vid;
// We want a new revision
$node->revision = 1;
// Required to get the data in the right format
content_submit($node);
// Save the node
node_save($node);
// Record that this comment added a revision
db_query('INSERT INTO {comment_cck_revisions} (cid, vid, nid, previous_vid) VALUES (%d, %d, %d, %d)', $comment['cid'], $node->vid, $node->nid, $previous_vid);
for example i have a field called 'status' , when i look at the $node struct in content_save when i goto node/60/edit i get
...[field_status] => Array
(
[tids] => 15
)
...
But the node structure on this 'insert' statement is completely wrong
[field_status] => Array
(
[0] => Array
(
[15] => stdClass Object
(
[tid] => 15
[vid] => 1
[name] => tested ok, ready to go live
[description] =>
[weight] => -7
)
)
)
If i insert "$node->field_status=array('tids'=>15);" after the node_load in the 'insert' hook it correctly saves the field_status data.
So the problem is that it's not loading the node in the same structure as what it needs when it submits it.
#3
Please try testing this on the latest release.
Patches welcomed. :)
#4
Closing old bug reports.