Closed (fixed)
Project:
Drupal core
Version:
x.y.z
Component:
upload.module
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
26 Dec 2005 at 16:41 UTC
Updated:
30 Mar 2006 at 15:33 UTC
Jump to comment: Most recent file
Select the file you wish to upload. Click the "attach" button. Now uncheck the "list" button next to the file you have just uploaded. Now submit the node.
The file will upload, but will have it's list property set to "1", i.e. it will be listed.
On a quick glance I can't see why this is.
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | 42358_5.patch | 21.2 KB | dopry |
| #44 | 42358_4.patch | 21.2 KB | dopry |
| #38 | 42358_3.patch | 21.19 KB | dopry |
| #36 | 42358_junyor.patch | 21.76 KB | junyor |
| #33 | 42358_2.patch | 21.25 KB | dopry |
Comments
Comment #1
chx commentedI know and I think today CVS is fixed, so please do a fresh checkout and check whether the bug is fixed or not. If you do not like it then by tomorrow morning the drupal-cvs.tar.gz will contain v 1.37 of form.inc which, I presume fixes the problem. Use that and please report back.
Comment #2
simon rawson commentedI have checked out the latest CVS HEAD versions of form.inc and upload.module but the bug has not been fixed, as far as I can see.
Comment #3
Steve Dondley commentedThis problem seems to have been fixed. I cannot duplicate.
Comment #4
simon rawson commentedAgreed. This doesn't exist on the latest HEAD.
Comment #5
Zen commentedI believe this is the same issue.. This is with current HEAD.
Delete:Off
List:On
Delete:On
List:On
Delete:Off
List:Off
-K
Comment #6
Tobias Maier commentedhad the problem today in a current cvs head version:
i repost what a wrote i another issue:
Comment #7
simon rawson commentedThis still exists.
Put simply, when you first submit a node, any new file attachments IGNORE their list / delete checkbox values and the system treats them as unchecked.
Comment #8
Zen commentedComment #9
junyor commentedAlso see http://drupal.org/node/46886 and http://drupal.org/node/47660.
The problem is that the list parameter is set to the fid. When a new attachment is uploaded, it doesn't have an fid, so list is set to 0.
Comment #10
jbrauer commentedThis is a critically needed fix for 4.7 release. While there is a workaround this is key functionality and will reflect poorly on the Drupal project.
Comment #11
Caleb Case commentedYup. There is no file id to associate the new uploads to until after one is generated when first inserting them. Here's a patch that updates the values based on what is passed in at the time (namely the list array contains stuff like ([upload_1] => upload_1, [upload_2] => upload_2, [upload_3] => 0) which can be used to figure out what the setting should be.)
Comment #12
junyor commentedI don't think that's a good fix. We should correct list so it's a BOOL, rather than the fid.
Comment #13
Caleb Case commentedThis will put the right value in the table. Maybe someone can come up with a more elegant solution? Maybe change the form values to return 0 or 1 instead of 0 or 'upload_#'?
Comment #14
Caleb Case commentedA unified patch file instead of the raw diff from last time.
Comment #15
simon rawson commented+1 from me. This is my biggest annoyance in Drupal at the moment, by far! Nice patch.
Comment #16
Tobias Maier commentedthere is a patch, right?
Comment #17
Tobias Maier commentedthere is a patch, right?
Comment #18
junyor commentedNo offense, ln, but -1 on this patch. We should fix the root problem, not hide it.
Comment #19
moshe weitzman commentedjunyor is an authority on upload matters: needs work
Comment #20
moshe weitzman commentedCould someone please look into this? it is a legitimate critical bug AFAICT.
Comment #21
dopry commentedI'll pick it up... I think I know whats going on.
Comment #22
dopry commentedI'll pick it up...
Comment #23
moshe weitzman commentedComment #24
dopry commentedThis patch has some major changes in it...
1) the list value case for this issue is fixed... and also another issue I found with check boxes has been worked around to set the list value on a direct submit w/o attach or preview. Extended notes in comments.
2) upload_nodeapi op = validate has been spread across prepare and validate hooks, and moved to _upload_prepare and _upload_validate.
3) multiple upload_load calls have been eliminated.
4) _SESSION['file_uploads'] renamed to _SESSION['file_previews'] to remove the interaction between the fileapi
and the upload.module via the session to help decouple the two.
5) the file form has been redesigned to mimick the node->files structure so the form API can handle some of the heavy lifting. (minus the checkbox on submit bug).
I know this change seems to go beyond the original issue, but changing the form structure was the best way I could think to eliminate this bug, and let the FAPI do the work. The rest of the changes flow from debugging that change.
I may be able to role a patch with less changes, but I would really like to see the upload module get some much needed cleaning up before 4.7rc.
.darrel.
Comment #25
dopry commentedbtw. The above patch depends on the last patch I posted to http://www.drupal.org/node/5961 as of 3/7/06...
My time is a little limited this week... but I'll do what it takes to see this patch through. so please post your feedback.
Comment #26
dopry commentedAnd the earlier patch is the wrong patch. File deletion doesn't work.
Comment #27
m3avrck commenteddopry, awesome job!
However, running into a problem on Windows, my uploads aren't going into the right direction, it is say right below the file:
http://localhost/drupal_devel/drupal/files/c:/windows/temp/tmp68C.tmp
instead of:
http://localhost/drupal_devel/drupal/files/tinymce.patch
Comment #28
dopry commentedI think the incorrect path is coming from my file_check_upload changes.
I haven't experienced the same issue on linux...
Does the something similar happen before applying this patch, but after the file_check_upload patch from http://www.drupal.org/5961?
Comment #29
dopry commentedAfter some playing m3avrck and I figured out there was bug with the _upload_form: $description = '' line.
So here is the updated version.
Thank you for your help m3avrck.
.darrel.
Comment #30
dopry commentedUpdating status...
Comment #31
jose reyero commentedThe patch has a minor problem -php tag at the top- but once fixed it works.
Not that I understand all the code in upload module - actually I feel a bit sick every time I try to :-( - so all I've done is apply the patch and test. Works as expected.
Comment #32
dries commentedThis looks like a really complex patch, for what looks like a simple problem. Sure this is the right approach?
Comment #33
dopry commentedI think it is the right approach. I agree it oversteps the original issue.
1) it solves the issue.
2) I think it make upload.module much easier to understand.
3) It addresses several issues that make upload.module difficult to debug.
--the multiple upload_load calls.
--the unintuitive node->list and node->remove
4) properly uses nodeapi prepare and validate. To bring interaction of contrib modules
with the core upload process closer to reality... (You can do a lot with module weighting and a new theme function for the current files form).
I strongly believe it is the best solution. (I wrote it so why shouldn't I.) I think the current upload.module is very difficult to understand, while my patch doesn't make it a childrens novel, I think it is a step in the right direction that will mean it easier for people to understand the current upload process (which hasn't really changed). It delineates the upload process in concise steps with better terminology that people are familiar with through nodeapi. It is better documented.
I would rather have an upload.module I can understand, than one that has received another piece of duct tape.
I will even keep myself on tap to fix any issues that arise as a result of this patch.
If the naysayers are loud and well spoken I will figure out where to apply the duct tape. I really want to see 4.7rc asap, which I was I have my own reservations regarding this patch and the depths of its changes, but I also abhor upload.module in its current state.
.darrel.
Comment #34
dries commentedThanks for the comments.
I think I would be OK with this patch. However, parts of the patch are hack-ish (like the way you use sessions). That stops me from committing it. That and the size of the patch; it takes a while to grok it properly.
Also, FAPI is not an official term. Better to refer to it as "forms API".
Comment #35
dopry commentedWhich use of sessions? The checkbox issue, or for storing upload_previews before submission across multiple page views?
The checkbox issue I have not been able to think of a way around, except for fixing for building to do the same thing... I went over that issue with hunmonk as well in IRC and he coudln't think of a better solution either.
For tracking uploads, it is the way it was done historically, and I think may be necessary to get the information into hook_menu to build the callback for previews, but I may be incorrect there. I didn't question that part I just kept it intact within the upload module, and changed the key so there would no longer be any hidden interaction with file.inc.
If you will expand on how the use of sessions is hack-ish I will address it.
Comment #36
junyor commentedI had a look through the patch and quite like what I see. The code is now much clearer and cleaner. Excellent work, dopry.
I noticed a couple lingering todos notes that need to be taken care of. What needs to be done to the delete functions? There's also a note to add the default new file list behavior to the file settings page. However, isn't file->list already set at that point (in upload_save)? I'm not opposed to a setting, but we should use it when file->list is originally set in _upload_prepare.
Isn't "file_check_upload('upload')" more or less meaningless or have you changed that recently? If it still means nothing, I'd like to see a better call to file_check_upload() in _upload_prepare().
Other than these issues, I noticed a couple style problems ("strpos($fid,'upload')" instead of "strpos($fid, 'upload')"). I'm attaching a patch with some documentation updates, too.
It looks like there's only one call to file_check_upload() left (in _upload_prepare). If _upload_prepare is only called once, this patch should also solve the mime magic bug.
Comment #37
dopry commentedI think the delete functions are fine as they are.. I just see very similar code in all of them that I think could be reduced into an _upload_delete_file().
Not it is not set. This is where the checkbox bug I mention sets the checkbox value to 0.
However I should use the variable_get('upload_file_list') in _upload_prepare If I am going to add it to the settings.
It has more or less the same meaning as file_check_upload().
I left the @todo's seperate. I felt I was already introducing enough change with this patch. I didn't want to push it.
I felt those changes could be more easily seperate into their own patches, and were just sideline thoughts I had while working on the listing options theory...
Comment #38
dopry commentedI addressed Junyor's issues with the code style,
remove FAPI as per Dries comments,
added the setting for default listing behavior that was a todo,
removed the todo's regarding refactoring the deletes.
fixed my comments to use the word hack less, and explain my use of session['file_submitted'] more clearly.
@Dries... I would still like verification from you about which use of _SESSION is hackish or if it is both, and why it is so.
Comment #39
junyor commented@dopry: Could you merge in the documentation updates I made?
Comment #40
dopry commented@Junyor as far as I can tell I have. Are there any you see that I missed... I just glanced over both patches again, and didn't seen anything.
Comment #41
jose reyero commented#32 Dries > This looks like a really complex patch, for what looks like a simple problem.
I think this is the question. But that is just a consequence of the upload mechanism and the upload module being quite a complex thing.
IMHO what we need, if not for Drupal 4.7, maybe for the next one, is to rewrite the whole thing and to get rid of session variables, using instead the files table -with temporary entries that can be cleaned up on cron later.
The thing is, using session variables to keep track of temporary files in the filesystem has the potential -quite real I'd say- risk of letting forgotten files around. Another issue, is that, using temporary names for files that are kept in the session variables may cause clashes if two users try to upload a file with the same name at the same time.
About this patch, I say +1 as it fixes the problem for now and is not more hackish than the upload module itself. But I'd like to think of something better for the long term.
Comment #42
dopry commentedThe abandoned files in Drupal's Tmp directory is something I noted in my file_check_upload patch. Before that patch landed files stayed in php's upload_tmp_dir until file_save_upload was called. Since php has its own garbage collection system it will clean them out. I have a patch that implements a similar garbage collection for drupal.
Filenaming is a non-issue, since filemove is called with $replace = FILE_EXISTS_RENAME in file_save_upload.
Comment #43
junyor commented@dopry: I changed the following: "Clean up old file previews if a post didn't get us to this page. IE) we left the edit page, because we didn't want to upload anything."
to:
"Clean up old file previews if a post didn't get the user to this page, i.e. the user left the edit page, because they didn't want to upload anything."
Comment #44
dopry commentedHere you go...
Comment #45
dopry commentedThere was an error in upload_save. I wasn't make sure node->files was an array before using it in a foreach loop.
Here is the update.
Comment #46
simeThere are a lot of changes which, for obvious reasons, make people nervous coming up to 4.7rc. So, therefore I will do comprehensive testing on this. For example, I will be trying various file types, extension-less file types, corrupt images, and so on. I'll check out personal and public uploads by various users types. I'll browse the hooks and create situations to test them as well.
Any specific requests about functions that should be tested?
#45 - Also, just to be sure, is this a unified patch to be applied to HEAD?
Comment #47
dopry commentedYes it is a unfied patch against head.
Comment #48
moshe weitzman commentedapplied the patch and browsed to node/add/story. got an immediate error: Missing argument 1 for file_check_upload(). the backtrace (with function arguments) is below. read it from the bottom up. we probably don't need to check_upload when first diaplaying the 'add' page:
9 node_invoke_nodeapi(class stdClass {var $uid = '1'; var $name = 'weitzman'; var $type = 'story'; var $created = 1141960087; var $date = '2006-03-10 03:08:07 +0000'; var $comment = 2}, 'prepare') /Library/WebServer/Documents/dpr/modules/node.module:1669
10 upload_nodeapi(class stdClass {var $uid = '1'; var $name = 'weitzman'; var $type = 'story'; var $created = 1141960087; var $date = '2006-03-10 03:08:07 +0000'; var $comment = 2}, 'prepare', NULL, NULL) /Library/WebServer/Documents/dpr/modules/node.module:317
11 _upload_prepare(class stdClass {var $uid = '1'; var $name = 'weitzman'; var $type = 'story'; var $created = 1141960087; var $date = '2006-03-10 03:08:07 +0000'; var $comment = 2}) /Library/WebServer/Documents/dpr/modules/upload.module:314
12 file_check_upload() /Library/WebServer/Documents/dpr/modules/upload.module:18
Comment #49
moshe weitzman commentedoops. my checkout was stale ... i tested this patch and it certainly fixes the critical bug. code style looks good, RTBC
Comment #50
dries commentedCommitted to HEAD. Great job!
Comment #51
(not verified) commentedComment #52
moshe weitzman commentedi am seeing the list checkbox disabled by default for new uploads. i had never changed that setting on admin/settings/upload, and the admin page said 'enabled' for this. i then explicitly set this to disabled and then enabled and drupal behaved as epected. i wonder if there isn't a bug here in the case where the variable is not set.
Comment #53
dopry commentedPlease open new bugs in new issues.... I don't want to confuse a settings problem with the changes made to upload.module.
Comment #54
dopry commentedI created a new issue http://www.drupal.org/node/56555 for thsi settings issue.