Commit f604b43
committed
issue2550929 fix for my use case, need Ralf to check for his.
While working from Ralf's latest notes, I identified three cases:
1) File exists but content is empty.
Remove content from form so file contents are not clobbered.
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.
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).
3 may be controversial.
We can't remove the content field as in 1. For new files there
MUST be a content field otherwise we generate the "Edit Error:
'content'" message to the user.
We can't treating the entry as in 2 and transparently remove the
reference to the new file id when content is empty, This will stop the
file from being created and will be confusing as the user won't see the
(0 length) file created and there will be no feedback.
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 Ralf 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.
There are no tests as I am not sure how to make/run tests cases with
alternate schemas required to make this testable.1 parent 506ea6c commit f604b43
1 file changed
+23
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
597 | | - | |
598 | | - | |
599 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
600 | 618 | | |
601 | 619 | | |
| 620 | + | |
| 621 | + | |
602 | 622 | | |
603 | 623 | | |
604 | 624 | | |
| |||
0 commit comments