From d048681f03b495256dbd52672a2a6e717425a5b0 Mon Sep 17 00:00:00 2001
From: Neil Drumm <drumm@3064.no-reply.drupal.org>
Date: Sun, 2 Jul 2006 20:24:17 +0000
Subject: [PATCH] #63990 by Heine and chx, allow commenting on nodes containing
 forms

---
 includes/form.inc              | 10 +++++++++-
 modules/comment.module         |  2 +-
 modules/comment/comment.module |  2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/includes/form.inc b/includes/form.inc
index 79c587bcff70..55910c175eaa 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -60,6 +60,11 @@ function element_children($element) {
  */
 function drupal_get_form($form_id, &$form, $callback = NULL) {
   global $form_values, $form_submitted, $user, $form_button_counter;
+  static $saved_globals = array();
+
+  // Save globals in case of indirect recursive call
+  array_push($saved_globals, array($form_values, $form_submitted, $form_button_counter));
+
   $form_values = array();
   $form_submitted = FALSE;
   $form_button_counter = array(0, 0);
@@ -155,7 +160,10 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
     }
   }
 
-  return form_render($form);
+  $output = form_render($form);
+  // Restore globals
+  list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals);
+  return $output;
 }
 
 function drupal_validate_form($form_id, $form, $callback = NULL) {
diff --git a/modules/comment.module b/modules/comment.module
index bb96f6d27501..46dce36ba4d8 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -1450,7 +1450,7 @@ function comment_form_add_preview($form, $edit) {
     $output .= theme('comment_view', $comment);
   }
   else {
-    $output .= node_view(node_load($edit['nid']));
+    $form['#suffix'] = node_view(node_load($edit['nid']));
     $edit['pid'] = 0;
   }
 
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index bb96f6d27501..46dce36ba4d8 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -1450,7 +1450,7 @@ function comment_form_add_preview($form, $edit) {
     $output .= theme('comment_view', $comment);
   }
   else {
-    $output .= node_view(node_load($edit['nid']));
+    $form['#suffix'] = node_view(node_load($edit['nid']));
     $edit['pid'] = 0;
   }
 
-- 
GitLab