Steps to reproduce:

1. Enable upload module
2. Create a story or whatever
3. Attach a file.
4. Click Save.
5. File is gone; it's not there on node view, nor is it there when you go back and edit the node.

If you preview first and then submit, the file's there.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

julien’s picture

I have reproduce this issue, and i have seen that when you save before the preview, it appears in the table file, but not in the table upload, which is the table used to see the files attachement.
I have insert manualy a record with the fid of the file in the table file, and now it appears.
I'm trying to locate where is the sql query and i will change it when i will find it.
If someone know in which file is this query, it will help me.

Gábor Hojtsy’s picture

Oh, this would be great to get fixed in beta 1 indeed.

drewish’s picture

it looks like the root of it is that hook_nodeapi($op='view') is now being called before hook_nodeapi($op='prepare'). prepare is where the files are attached. so if you click preview twice the files are attached properly.

fwalch’s picture

Status: Active » Needs review
FileSize
1.16 KB

I found out that if you just save the node, no files are attached to the node object. If you preview first, "_upload_prepare" is called, which attaches the files.
This patch checks if all files are attached to the node and adds missing ones, which fixes the bug.

drewish’s picture

Status: Needs review » Needs work

previews don't work. you still have to click preview twice.

julien’s picture

FileSize
950 bytes

I have apply the patch 46, and add a line in the case 'view' to prepare the node. It will put the file in the table upload only after clicking on save.

chx’s picture

I am on the case. Seems when saving a node form, nodeapi op prepare is not called. WTF?

chx’s picture

Title: upload module deletes files on submission » Cached node forms do not call op prepare
Assigned: Unassigned » chx
chx’s picture

Title: Cached node forms do not call op prepare » upload prepare is the wrong operation
Status: Needs work » Needs review
FileSize
3.99 KB

upload_prepare operates on submitted info, that hardly belongs to op prepare. I fixed a few notices as I went. The patch has known issues, on edit I got a surplus line saying "0 1" in the file attachment table, as time permits I will fix that. But essentially this works.

chx’s picture

Title: upload prepare is the wrong operation » *_node_form cache loading prevents files to be attached to node on direct save/update
Status: Needs review » Needs work

Twin issue was http://drupal.org/node/164674 but as I patched this, that one is now duplicate.

chx’s picture

Status: Needs work » Needs review

I have just tested the patch and it works. I suspect dvessel's patches...

dvessel’s picture

Status: Needs review » Reviewed & tested by the community

chx, I misunderstood.. The patch does indeed work. Got confused by how this issue was progressing so I never applied the patch. duh..

Not related to this, but in Safari 2 clicking the "attach" button shows the progress animation but never finishes. Just clicking save without previews works fine.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

OK, committed. Awating patches for the remaining issues.

Anonymous’s picture

Status: Fixed » Closed (fixed)