From 623397d6dd943e6477a6b339e01fe44a5de8c6db Mon Sep 17 00:00:00 2001
From: Kjartan Mannes <kjartan@2.no-reply.drupal.org>
Date: Thu, 17 Oct 2002 09:21:03 +0000
Subject: [PATCH] - fixing the logic for populating $node when adding a new
 node. Title, teaser,   body will now be set correctly, or be left unset if no
 values are included in   the request.

---
 modules/node.module      | 8 +++++++-
 modules/node/node.module | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/modules/node.module b/modules/node.module
index c0fd6ac16981..398404aee1de 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -928,7 +928,13 @@ function node_add($type) {
 
   if ($type && node_access("create", $type)) {
     // Initialize settings
-    $output = node_form(array("uid" => $user->uid, "name" => $user->name, "type" => $type, "status" => 1, "promote" => !module_exist("queue"), "moderate" => module_exist("queue"), "comment" => module_exist("queue") ? 2 : 0, "title" => check_input($edit["title"]), "body" => check_input($edit["body"])));
+    $node = array("uid" => $user->uid, "name" => $user->name, "type" => $type, "status" => 1, "promote" => !module_exist("queue"), "moderate" => module_exist("queue"), "comment" => module_exist("queue") ? 2 : 0);
+    foreach (array("title", "teaser", "body") as $field) {
+      if ($edit[$field]) {
+        $node[$field] = check_input($edit[$field]);
+      }
+    }     
+    $output = node_form($node);
   }
   else {
 
diff --git a/modules/node/node.module b/modules/node/node.module
index c0fd6ac16981..398404aee1de 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -928,7 +928,13 @@ function node_add($type) {
 
   if ($type && node_access("create", $type)) {
     // Initialize settings
-    $output = node_form(array("uid" => $user->uid, "name" => $user->name, "type" => $type, "status" => 1, "promote" => !module_exist("queue"), "moderate" => module_exist("queue"), "comment" => module_exist("queue") ? 2 : 0, "title" => check_input($edit["title"]), "body" => check_input($edit["body"])));
+    $node = array("uid" => $user->uid, "name" => $user->name, "type" => $type, "status" => 1, "promote" => !module_exist("queue"), "moderate" => module_exist("queue"), "comment" => module_exist("queue") ? 2 : 0);
+    foreach (array("title", "teaser", "body") as $field) {
+      if ($edit[$field]) {
+        $node[$field] = check_input($edit[$field]);
+      }
+    }     
+    $output = node_form($node);
   }
   else {
 
-- 
GitLab