From 7c7065f526bdd1af4b559297efb61d445b1d30cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= <gabor@hojtsy.hu>
Date: Wed, 19 May 2010 14:43:56 +0000
Subject: [PATCH] #323438 by emok, chx, mfb: uploaded files become arrays in
 previews, so object property checking will not work on them (from PHP
 5.2.12+)

---
 modules/upload/upload.module | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 49346449079a..53d79c74186a 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -189,6 +189,9 @@ function upload_node_form_submit(&$form, &$form_state) {
 
   if (isset($form_state['values']['files'])) {
     foreach ($form_state['values']['files'] as $fid => $file) {
+      // If the node was previewed prior to saving, $form['#node']->files[$fid]
+      // is an array instead of an object. Convert file to object for compatibility. 
+      $form['#node']->files[$fid] = (object) $form['#node']->files[$fid];
       $form_state['values']['files'][$fid]['new'] = !empty($form['#node']->files[$fid]->new);
     }
   }
-- 
GitLab