--- attachment.module 2008-12-17 08:24:29.000000000 -0600 +++ attachment.module.new 2008-12-17 08:28:40.000000000 -0600 @@ -122,6 +122,7 @@ function attachment_nodeapi(&$node, $op, case 'insert': case 'update': + $i = 0; foreach ((array)$node->attachments as $attachment) { if (!$attachment['deleted']) { module_invoke('filemanager', 'promote_working', $attachment['fid']); @@ -131,6 +132,7 @@ function attachment_nodeapi(&$node, $op, else { $aid = db_next_id('{attachment}_aid'); db_query("INSERT INTO {attachment} (aid,title,description,nid,fid,filename,size,hidden) VALUES (%d,'%s','%s',%d,%d,'%s',%d,'%s')", $aid, $attachment['title'],$attachment['description'],$node->nid, $attachment['fid'], $attachment['filename'], $attachment['size'], $attachment['hidden']); + $node->attachments[$i]['aid'] = $aid; } } else { @@ -139,6 +141,7 @@ function attachment_nodeapi(&$node, $op, db_query("DELETE FROM {attachment} WHERE aid=%d",$attachment['aid']); } } + $i++; } return;