Message5914
Hi Ralf:
Looks like your reply got caught in my spam trap I missed seeing it when
I emptied my spam folder. Sorry about that.
Your initial fix didn't work. I never have a content key since there
is no message. As a result your if clause was never entered. While I
was working on it, I identified three cases:
1) File exists but content is empty.
Remove content from form so file contents are not clobbered.
This is I believe your use case.
2) New file to be created (id is -1, -2 ...) but there is no
content field defined in form. Remove all fields referencing
the new id. This is my original use case.
3) New file to be created (id is -1, -2 ...) and there is a content
field defined in form. Let it be processed normally with no
changes. Do this even if the content value is empty (allow
uploading empty files). I tried uploading 0 length file during
manual testing expecting it to fail and it did. So I got another
use case 8-).
How I handle 3 may be controversial but:
we can't remove the content field as in case 1. New files
MUST have a content field otherwise we generate the very
unfriendly
"Edit Error: 'content'"
message to the user.
We can't treat the entry as in case 2 and transparently remove the
reference to the new file id when content is empty, This will
stop the file from being created. But it will be confusing to
the user as s/he won't see the (0 length) file created and there
will be no feedback. I don't think adding: "your file xyzzy was not
created" as part of an OK message is ok (even if I could figure out
how to add that up to the UI).
We could:
Return an error to the user telling them they can't upload an
empty file.
But why ask the user to resubmit just because of a 0 length file?
Also although you did a great job retaining all form values on an
error, it looks like the file upload element of the form doesn't get
it's values retained. (Indeed this may be impossible to do. I don't
want the server to be able to create a hidden file upload button
pre-filled with file names just waiting for me to submit the form.)
So accepting the 0 length file I think is the best alternative.
I got annoyed at having to reselect files to upload every time I hit an
error 8-).
There are no tests as I am not sure how to make/run tests cases with
alternate schemas required to make this testable.
I checked my code changes in. Can you run your use case test against
it and make sure it works.
If it does, I'll close this ticket out.
-- rouilj |
|
Date |
User |
Action |
Args |
2016-10-22 21:36:07 | rouilj | set | messageid: <1477172167.56.0.693414264259.issue2550929@psf.upfronthosting.co.za> |
2016-10-22 21:36:07 | rouilj | set | recipients:
+ rouilj, schlatterbeck |
2016-10-22 21:36:07 | rouilj | link | issue2550929 messages |
2016-10-22 21:36:05 | rouilj | create | |
|