Attachment created twice - conflict with Actions module

streetdaddy - March 19, 2008 - 07:47
Project:Attachment
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

When creating a new node, if I set the Workflow to use an Action that publishes the node, after submitting the node any attachments added are duplicated in the list when viewing the node. The file is not duplicated in the file system. Going back to edit there are now two identical attachments. Deleting one leaves the other in the db, but the the file is no longer in the file system so the left over attachment link is invalid.

I am using Actions and Workflow modules in my site and have discovered an issue similar to http://drupal.org/node/72039. I used the same method as http://drupal.org/node/72039#comment-423039 to fix the problem, ie.

The solution was to unset $node->attachments before the action re-saved the node.

In actions.inc, action_node_publish(), I added the following line:

unset($node->attachments);

... just before

node_save($node);

This solved the problem, but is there a better solution that can be applied through the attachment module?

#1

zbricoleur - December 17, 2008 - 14:33

I "fixed" it in attachment.module instead by altering the attachment_nodeapi function. Patch attached.

AttachmentSize
attachment.patch 1.13 KB
 
 

Drupal is a registered trademark of Dries Buytaert.