Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.611
diff -u -p -r1.611 common.inc
--- includes/common.inc	10 Jan 2007 23:30:07 -0000	1.611
+++ includes/common.inc	19 Jan 2007 17:10:00 -0000
@@ -2097,6 +2097,36 @@ function drupal_system_listing($mask, $d
   return $files;
 }
 
+
+/**
+ * This dispatch function hands off structured drupal arrays to
+ * type-specific hook_form_alter implementations. 
+ *
+ * @param $type
+ *   The data type of the structured array. 'form', 'links',
+ *   'node_content', and so on are some example values.
+ * @param $data
+ *   The structured array to be altered.
+ * @param ...
+ *   Any additional params will be passed on to the called
+ *   hook_$type_alter functions.
+ * @return
+ *   The altered version of the $data array.
+ */
+function drupal_alter($type, $data) {
+  $args = func_get_args();
+  // Strip out the first arg, because $type already contains it.
+  array_shift($args);
+
+  foreach (module_implements($type .'_alter') as $module) {
+    $function = $module .'_'. $type .'_alter';
+    $args[0] = $data;
+    $data = call_user_func_array($function, $args);
+  }
+  return $data;
+}
+
+
 /**
  * Renders HTML given a structured array tree. Recursively iterates over each
  * of the array elements, generating HTML code. This function is usually
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.174
diff -u -p -r1.174 form.inc
--- includes/form.inc	15 Jan 2007 04:09:40 -0000	1.174
+++ includes/form.inc	19 Jan 2007 17:10:00 -0000
@@ -360,10 +360,7 @@ function drupal_prepare_form($form_id, &
     }
   }
 
-  foreach (module_implements('form_alter') as $module) {
-    $function = $module .'_form_alter';
-    $function($form_id, $form);
-  }
+  $form = drupal_alter('form', $form, $form_id);
 
   $form = form_builder($form_id, $form);
 }
Index: modules/color/color.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/color/color.module,v
retrieving revision 1.13
diff -u -p -r1.13 color.module
--- modules/color/color.module	18 Dec 2006 11:59:07 -0000	1.13
+++ modules/color/color.module	19 Jan 2007 17:10:00 -0000
@@ -4,7 +4,7 @@
 /**
  * Implementation of hook_form_alter().
  */
-function color_form_alter($form_id, &$form) {
+function color_form_alter($form, $form_id) {
   // Insert the color changer into the theme settings page.
   // TODO: Last condition in the following if disables color changer when private files are used this should be solved in a different way. See issue #92059.
   if ($form_id == 'system_theme_settings' && color_get_info(arg(4)) && function_exists('gd_info') && variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) {
@@ -30,6 +30,7 @@ function color_form_alter($form_id, &$fo
       }
     }
   }
+  return $form;
 }
 
 /**
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.520
diff -u -p -r1.520 comment.module
--- modules/comment/comment.module	3 Jan 2007 11:32:38 -0000	1.520
+++ modules/comment/comment.module	19 Jan 2007 17:10:01 -0000
@@ -367,7 +367,7 @@ function comment_link($type, $node = NUL
   return $links;
 }
 
-function comment_form_alter($form_id, &$form) {
+function comment_form_alter($form, $form_id) {
   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
     $form['workflow']['comment'] = array(
       '#type' => 'radios',
@@ -396,6 +396,7 @@ function comment_form_alter($form_id, &$
       );
     }
   }
+  return $form;
 }
 
 /**
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.375
diff -u -p -r1.375 forum.module
--- modules/forum/forum.module	10 Jan 2007 15:17:51 -0000	1.375
+++ modules/forum/forum.module	19 Jan 2007 17:10:01 -0000
@@ -203,7 +203,7 @@ function forum_admin_settings() {
 /**
  * Implementation of hook_form_alter().
  */
-function forum_form_alter($form_id, &$form) {
+function forum_form_alter($form, $form_id) {
   // hide critical options from forum vocabulary
   if ($form_id == 'taxonomy_form_vocabulary') {
     if ($form['vid']['#value'] == _forum_get_vid()) {
@@ -222,6 +222,7 @@ function forum_form_alter($form_id, &$fo
       unset($form['nodes']['forum']);
     }
   }
+  return $form;
 }
 
 /**
Index: modules/menu/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v
retrieving revision 1.100
diff -u -p -r1.100 menu.module
--- modules/menu/menu.module	5 Jan 2007 19:05:54 -0000	1.100
+++ modules/menu/menu.module	19 Jan 2007 17:10:01 -0000
@@ -171,7 +171,7 @@ function menu_perm() {
  * Implementation of hook_form_alter().
  * Add menu item fields to the node form.
  */
-function menu_form_alter($form_id, &$form) {
+function menu_form_alter($form, $form_id) {
   if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
     $item = array();
     if ($form['nid']['#value'] > 0) {
@@ -241,6 +241,7 @@ function menu_form_alter($form_id, &$for
       );
     }
   }
+  return $form;
 }
 
 /**
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.776
diff -u -p -r1.776 node.module
--- modules/node/node.module	14 Jan 2007 02:12:29 -0000	1.776
+++ modules/node/node.module	19 Jan 2007 17:10:01 -0000
@@ -2483,7 +2483,7 @@ function node_update_index() {
 /**
  * Implementation of hook_form_alter().
  */
-function node_form_alter($form_id, &$form) {
+function node_form_alter($form, $form_id) {
   // Advanced node search form
   if ($form_id == 'search_form' && arg(1) == 'node' && user_access('use advanced search')) {
     // Keyword boxes:
@@ -2548,6 +2548,7 @@ function node_form_alter($form_id, &$for
 
     $form['#validate']['node_search_validate'] = array();
   }
+  return $form;
 }
 
 /**
Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.105
diff -u -p -r1.105 path.module
--- modules/path/path.module	9 Jan 2007 08:34:03 -0000	1.105
+++ modules/path/path.module	19 Jan 2007 17:10:01 -0000
@@ -255,7 +255,7 @@ function path_nodeapi(&$node, $op, $arg)
 /**
  * Implementation of hook_form_alter().
  */
-function path_form_alter($form_id, &$form) {
+function path_form_alter($form, $form_id) {
   if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
     $path = $form['#node']->path;
     $form['path'] = array(
@@ -281,6 +281,7 @@ function path_form_alter($form_id, &$for
       );
     }
   }
+  return $form;
 }
 
 
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.330
diff -u -p -r1.330 taxonomy.module
--- modules/taxonomy/taxonomy.module	11 Jan 2007 03:29:15 -0000	1.330
+++ modules/taxonomy/taxonomy.module	19 Jan 2007 17:10:02 -0000
@@ -659,7 +659,7 @@ function taxonomy_get_vocabularies($type
  * Implementation of hook_form_alter().
  * Generate a form for selecting terms to associate with a node.
  */
-function taxonomy_form_alter($form_id, &$form) {
+function taxonomy_form_alter( $form, $form_id) {
   if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
     $node = $form['#node'];
 
@@ -736,6 +736,7 @@ function taxonomy_form_alter($form_id, &
       $form['taxonomy']['#tree'] = TRUE;
     }
   }
+  return $form;
 }
 
 /**
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.148
diff -u -p -r1.148 upload.module
--- modules/upload/upload.module	15 Jan 2007 11:22:34 -0000	1.148
+++ modules/upload/upload.module	19 Jan 2007 17:10:02 -0000
@@ -338,7 +338,7 @@ function _upload_prepare(&$node) {
   }
 }
 
-function upload_form_alter($form_id, &$form) {
+function upload_form_alter($form, $form_id) {
   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
     $form['workflow']['upload'] = array(
       '#type' => 'radios',
@@ -393,6 +393,7 @@ function upload_form_alter($form_id, &$f
       }
     }
   }
+  return $form;
 }
 
 function _upload_validate(&$node) {
@@ -887,7 +888,7 @@ function upload_js() {
   $form = _upload_form($node);
   foreach (module_implements('form_alter') as $module) {
     $function = $module .'_form_alter';
-    $function('upload_js', $form);
+    $function($form, 'upload_js');
   }
   $form = form_builder('upload_js', $form);
   $output = theme('status_messages') . drupal_render($form);
