Upload module no longer work. nodeapi op=prepare is no longer called during when a node form is submitted.

The change that causes it is in drupal_get_form which uses the previously constructed form in the cache if it is available and the form is being submitted. This means node_form/node_object_prepare is never called on submit, and neither is form_alter, which is when/where upload.module currently adds new file data to the node and node_form respectively.

CommentFileSizeAuthor
#7 upload_previews_0.patch879 bytesdopry
#6 upload_previews.patch1.04 KBdopry
#2 157747.patch640 bytesdopry
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

related issue:
http://drupal.org/node/150463 => FAPI 3 problem -upload module fails when JS is disabled

See also the JS and callback here:
http://drupal.org/node/146425 => improve book module: use nodeapi and menu API

a second select is changed based on the first - and the cached form is altered to match. That's how eaton said to do FAPI3 AJAX: http://drupal.org/node/150859 (my writeup based on IRC w/ eaton and experimentation - put into practice in the book patch)

dopry’s picture

Status: Active » Needs review
FileSize
640 bytes

I found we can just disable the form caching for nodes with uploads.

moshe weitzman’s picture

would it be better to implement upload_nodeapi('presave') instead? see top of node_save(). if not, this patch looks fine to me.

pwolanin’s picture

Status: Needs review » Needs work

Disabling form caching potentially breaks all AJAX callbacks - perhaps Jeff Eaton has had some new insight into this problem?

dopry’s picture

I spoke with eaton a while back, he said the work of upload_prepare might be able to be done in a validate callback now. You should be able to set $form['#rebuild'] = TRUE in the validate callback to get the form properly rebuilt during submission. I haven't had any luck getting a validate callback called on the container for the upload form that contains the file data and new upload elements, and I currently have limited time resources to work on this. If someone else wants to run with it for a bit that would be awesome, unless some time magically appears for me in the next three weeks which I doubt I won't be able to work on this issue.

dopry’s picture

Title: Uploads Fail, nodeapi op = prepare no longer behaves as expected after FAPI3, due to form caching. » Attachments aren't rendered properly on node_preview due to a type error.
Status: Needs work » Needs review
FileSize
1.04 KB

Actually in a quick ping pong with eaton we figured out that currently there are only a couple issues with new attachments not being rendered properly on previews in the attachment form, and other wise upload.module seems to be mostly well behaved again, except the type casting issue in the attached patch.

dopry’s picture

FileSize
879 bytes

how about a patch without my debugging code.

drewish’s picture

Status: Needs review » Reviewed & tested by the community

works for me.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed!

Anonymous’s picture

Status: Fixed » Closed (fixed)