Loss of newly uploaded files during hook_form preview submissions

candelas - June 10, 2009 - 10:45
Project:Upload element
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Alan D.
Status:needs review
Description

hello

thanks a lot for the module.
i am using rotor banner which uses your module to upload the images.

i have the preference on "Administer > Content Management > Content Settings" that previews are required.

when i try to upload an image for banner, if i preview then the image will get lost.
i mean that i select the image, i can see the thumbanail but when i preview it gets lost.
if i try again to upload after the preview, then i get the error:
"Validation error, please try again. If this error persists, please contact the site administrator."
i saw that the image is copied to the files/tmp but it doesnt arrive to files/rotor

if i take off the preference on Content Settings of preview required, then it works perfect.

i have reported too in rotor banner but since i think it is related to this module, then i report here too :)
http://drupal.org/node/485078

sorry for the bad english :)

#1

Alan D. - June 10, 2009 - 11:18
Status:active» postponed (maintainer needs more info)

K, I think that this could be related to the workflow used by Rotor. I didn't attempt any form of Preview state when designing the form API element. Happy to work with the maintainer to assist with developing, but I do have limited time at the moment.

I do not think that the following will tell us anything new, but can help in general image problem solving.

If there were errors from the upload_element directly, the following could help to resolve the issue. (Again unlikely to help as the non-preview state works)

1) Are you getting PHP errors? Turn on error logging to see if anything is reported. This is one of the error messages that is given by upload_element module when there is a fatal error in the AHAH processing.

2) Is the form on a cached page? Forms should never reside in a cached environment.

3) Uploads are working, so I'm not going to mention the file directory permissions....

Couple possible workarounds for image errors. (Limited info, so just stabs in the dark)

1) Is it windows or unix server? There is a bug in PHP image processing in window servers that require the image extensions to match the extensions to use in the validation routine. Try using all uppercase for the extension that you are uploading. Only certain version of PHP have this error

2) Can you view the image locally in both IE and FF? IE is more sensitive to images and there may be an error in the image that does not pass validation in image info function call.

3) Make sure that the image is in RBG. Just open and save for web in Photoshop or another similar program and upload again.

#2

candelas - June 11, 2009 - 00:06

thank you for answering so fast :)

1) how do i Turn on error logging?

2) i dont think so, but since i didnt make the form, how do i can know?

3) :)

1) i have ubuntu 8.10 locally and the server is unix on internet.

2) i watch them with firefox and epiphany

3) rgb (if i have not the preview required i dont get the error)

thanks again and sorry i dont know much for being able to help in this...

#3

Alan D. - June 11, 2009 - 00:27
Title:preview in rotor module gives an error on validation upload» Loss of newly uploaded files during hook_form preview submissions
Version:6.x-1.2» 6.x-1.x-dev
Component:User interface» Code
Assigned to:Anonymous» Alan D.
Status:postponed (maintainer needs more info)» active

I think is related to a changing form ID in the node preview form. I haven't the time to look into this for a couple weeks, but will add this as a potential issue. Not sure if it is a flaw in the local logic here or something that is not being taken into account in Rotor. We never program using the node preview state, so I'm very green myself in this area.

As a temp. fix, try disabling preview on the Rotor node type.

Note to self: Check the FAPI hooks called during multistep forms / non-rebuilt forms and see if the form build id changes.

#4

candelas - June 11, 2009 - 01:34

thanks :)

#5

Alan D. - June 24, 2009 - 10:43
Status:active» needs review

The latest dev version has a version for community testing. It should be packaged in the next 24 hours.

This is a semi-complete workaround for issues related to a changing form build id when a form is rebuilt. More time is required to see why the AHAH callback is still using the old form build id, and not getting reprocessed with the element.

In english, this means that users will still get the same error when uploading a previewed form with a file that exceeds PHP max post size limit. Hitting preview again will refresh the image element.

Since, no longer critical, I'll close this issue after testing. Drupal 7 is introducing a lot of form API enhancements, such as passing the $form_state variable to the hook_ELEMENT_value() function call, which should eliminate the need to use $_SESSION directly, and many more. Hopefully the AHAH framework gets refactored too!

 
 

Drupal is a registered trademark of Dries Buytaert.