I encountered it while working on my GSoC proposal, FBSMP. Here are the steps to reproduce this on the imagefield settings page:

1) browse default image.
2) save settings.

Edit again

3) enter -1 in max resolution.
4) browse a default image.
5) save settings.

Now, the default image is lost. It happens because of the following:

1) validation error for max resolution field happens.
2) file for default image is uploaded successfully and old file is removed.
3) new file object (array) is added to the $form_state.
4) But as form is not submitted, filepath for this new image is not stored in the settings. Hence, old file is lost but is referenced in the settings whereas new image is uploaded and not saved in the settings for default image.

I just hope it is clear enough.

Thanks,

CommentFileSizeAuthor
#2 imagefield_validation_check.patch915 bytesquicksketch

Comments

quicksketch’s picture

Thanks for the excellent report! I'll give this a look shortly. It would be rather easy to simply check form_get_errors() before deleting the existing image. I'm not sure we'll be able to save the default image entirely just on validation.

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new915 bytes

I've committed this patch which prevents the problem of the default image being lost. Unfortunately it's very difficult to accept the new image temporarily until the "save" button is clicked again, so this only mitigates the problem by not deleting the previous default image accidentally. End-users will need to select the file again after validation fails.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.