In testing http://drupal.org/node/185244 I noticed a rather serious bug in how project_release handles file attachments when cvslog.module is disabled. Not sure when this was broken, but at least on my test site, if you try to manually attach a file to a release node (not via upload.module, but the hard-coded file attachment stuff), it saves the record in the {project_release_nodes} table using the tmp filepath, not the real one. Something about how the preview workflow is happening is screwing things up.
A little debugging shows that by the time we hit project_release_db_save() on the initial submit of the release node, $node->file_path is already set to, for example "/tmp/foo.txt". At that point, $file_data->filepath is correctly set to "files/foo.txt".
So, the bug is in this bit of logic:
'file_path' => $node->file_path ? $node->file_path : $file_data->filepath,
That's the wrong way to go about it. Instead of seeing if $node already has a value, we should just see if we got a new file_path from $file_data, and if not, fall back to what's already in $node.
Attached patch works fine with my local testing, but I wouldn't mind more tests and an independent review. ;)
| Comment | File | Size | Author |
|---|---|---|---|
| project_release_file_attach.patch | 1.32 KB | dww |
Comments
Comment #1
aclight commentedThis must be a relatively new bug because I turned off cvs on my site and tried adding a release by uploading a file and didn't get the bug.
So I tested project -dev on my test site, and was able to reproduce the problem.
The patch looks good and works right with one possible exception. If I click add new release, then upload a file and fill in body, version number fields, etc. and then click preview, the URL for the release file I just uploaded is http://www.example.com/drupal/files//tmp/test.txt (note the two slashes between files and tmp). But then if I click submit, the file is uploaded correctly.
So I'm not sure if what I'm describing when clicking preview is a bug or is as intended.
If it's a bug, I don't think it's created by this patch, because it still happens when I revert the patch in this issue. If it's not a bug or not something that needs to be addressed in this issue then I'd call this RTBC.
Comment #2
dwwThis was probably introduced via http://drupal.org/node/155697 (revision 1.50 of project_release.module).
I think that preview stuff you're noticing was broken around the same time, and my patch doesn't make it any worse, so I don't see any burning need to hold this up until that's resolved. Therefore, my original patch still needs review. Updating status accordingly (guess I forgot to set this to CNR in the first place).
Also, a large part of me wants to rip out all this custom file handling entirely and move to upload.module for files attached to issues, although that has big implications for other parts of the project_release UI. :(
Comment #3
aclight commentedSorry I wasn't clear. I think you're right about the preview issues, so I've marked this as RTBC.
Comment #4
dwwCommitted to HEAD. Since http://drupal.org/node/155697 wasn't backported, this bug was only present in HEAD. Thanks for the review.
Comment #5
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.