Index: includes/ajax.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/ajax.inc,v
retrieving revision 1.8
diff -u -p -r1.8 ajax.inc
--- includes/ajax.inc	5 Sep 2009 15:05:01 -0000	1.8
+++ includes/ajax.inc	18 Sep 2009 16:52:07 -0000
@@ -214,14 +214,20 @@ function ajax_form_callback() {
   if (function_exists($callback)) {
     $html = $callback($form, $form_state);
 
-    // If the returned value is a string, assume it is HTML and create
-    // a command object to return automatically.
+    // If the returned value is a string, assume it is HTML, add the status
+    // messages, and create a command object to return automatically. We want
+    // the status messages inside the new wrapper, so that they get replaced
+    // on subsequent AJAX calls for the same wrapper.
+    // @see ajax_command_replace()
     if (is_string($html)) {
       $commands = array();
       $commands[] = ajax_command_replace(NULL, $html);
+      $commands[] = ajax_command_prepend(NULL, theme('status_messages'));
     }
     // Otherwise, $html is supposed to be an array of commands, suitable for
-    // Drupal.ajax, so we pass it on as is.
+    // Drupal.ajax, so we pass it on as is. In this situation, the callback is
+    // doing something fancy, so let it decide how to handle status messages
+    // without second guessing it.
     else {
       $commands = $html;
     }
@@ -370,6 +376,19 @@ function ajax_command_alert($text) {
  * This command is implemented by Drupal.ajax.prototype.commands.insert()
  * defined in misc/ajax.js.
  *
+ * When using this command, it is likely that any status messages shall be
+ * output with the given HTML. In case an AJAX callback returns a HTML string
+ * instead of an AJAX command structure, ajax_form_callback() automatically
+ * prepends the returned output with status messages.
+ * To achieve the same result using an AJAX command structure, the AJAX callback
+ * may use the following:
+ * @code
+ *   $commands = array();
+ *   $commands[] = ajax_command_replace(NULL, $output);
+ *   $commands[] = ajax_command_prepend(NULL, theme('status_messages'));
+ *   return $commands;
+ * @endcode
+ *
  * @param $selector
  *   A jQuery selector string. If the command is a response to a request from
  *   an #ajax form element then this value can be NULL.
Index: modules/field/field.form.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.form.inc,v
retrieving revision 1.24
diff -u -p -r1.24 field.form.inc
--- modules/field/field.form.inc	10 Sep 2009 22:31:58 -0000	1.24
+++ modules/field/field.form.inc	18 Sep 2009 16:52:40 -0000
@@ -362,9 +362,5 @@ function field_add_more_js($form, $form_
   $field_form[$langcode][$delta]['#prefix'] = '<div class="ajax-new-content">' . (isset($field_form[$langcode][$delta]['#prefix']) ? $field_form[$langcode][$delta]['#prefix'] : '');
   $field_form[$langcode][$delta]['#suffix'] = (isset($field_form[$langcode][$delta]['#suffix']) ? $field_form[$langcode][$delta]['#suffix'] : '') . '</div>';
 
-  $output = theme('status_messages') . drupal_render($field_form);
-
-  $commands = array();
-  $commands[] = ajax_command_replace(NULL, $output);
-  ajax_render($commands);
+  return drupal_render($field_form);
 }
Index: modules/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.313
diff -u -p -r1.313 poll.module
--- modules/poll/poll.module	18 Sep 2009 00:12:47 -0000	1.313
+++ modules/poll/poll.module	18 Sep 2009 16:42:30 -0000
@@ -382,7 +382,7 @@ function _poll_choice_form($key, $chid =
 function poll_choice_js($form, $form_state) {
   $choice_form = $form['choice_wrapper']['choice'];
 
-  return theme('status_messages') . drupal_render($choice_form);
+  return drupal_render($choice_form);
 }
 
 /**
