From 18d532e214d46a5422b1d40f3ac7eecd798e8b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Wed, 21 Nov 2007 19:13:22 +0000 Subject: [PATCH] #172630 by webernet: fix weird errors experienced when using the JS file uploader --- modules/upload/upload.module | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/upload/upload.module b/modules/upload/upload.module index 1c9733ec794..e31efeee713 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -561,12 +561,15 @@ function upload_js() { // We only do the upload.module part of the node validation process. $node = (object)$_POST; $form_state = array(); + // Handle new uploads, and merge tmp files into node-files. upload_node_form_submit(array(), $form_state); - $node->files = array_merge(isset($form_state['values']['files']) ? $form_state['values']['files'] : array(), upload_load($node)); - - $files = isset($_POST['files']) ? $_POST['files'] : array(); - + $node->files = upload_load($node); + if (!empty($form_state['values']['files'])) { + foreach($form_state['values']['files'] as $fid => $file) { + $node->files[$fid] = $file; + } + } $form = _upload_form($node); $form += array( @@ -580,9 +583,12 @@ function upload_js() { $form = form_builder('upload_js', $form, $form_state); // Maintain the list and delete checkboxes values. + $files = isset($_POST['files']) ? $_POST['files'] : array(); foreach ($files as $fid => $file) { - $form['files'][$fid]['list']['#value'] = isset($file['list']) ? 1 : 0; - $form['files'][$fid]['remove']['#value'] = isset($file['remove']) ? 1 : 0; + if (is_numeric($fid)) { + $form['files'][$fid]['list']['#value'] = isset($file['list']) ? 1 : 0; + $form['files'][$fid]['remove']['#value'] = isset($file['remove']) ? 1 : 0; + } } $output = theme('status_messages') . drupal_render($form);