Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.848
diff -u -p -r1.848 common.inc
--- includes/common.inc	14 Jan 2009 21:13:41 -0000	1.848
+++ includes/common.inc	16 Jan 2009 15:41:09 -0000
@@ -3168,9 +3168,10 @@ function drupal_alter($type, &$data) {
   array_shift($additional_args);
   $args = array_merge($args, $additional_args);
 
+  $args += array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
   foreach (module_implements($type . '_alter') as $module) {
     $function = $module . '_' . $type . '_alter';
-    call_user_func_array($function, $args);
+    $function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9]);
   }
 }
 
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.310
diff -u -p -r1.310 menu.inc
--- includes/menu.inc	4 Jan 2009 20:04:32 -0000	1.310
+++ includes/menu.inc	16 Jan 2009 15:41:10 -0000
@@ -218,12 +218,16 @@ define('MENU_MAX_PARTS', 7);
  */
 define('MENU_MAX_DEPTH', 9);
 
-
 /**
  * @} End of "Menu tree parameters".
  */
 
 /**
+ * The maximum number of arguments a load function may take.
+ */
+define('MENU_MAX_LOAD_ARGS', 5);
+
+/**
  * Returns the ancestors (and relevant placeholders) for any given path.
  *
  * For example, the ancestors of node/12345/edit are:
@@ -398,7 +402,8 @@ function menu_execute_active_handler($pa
   if ($router_item = menu_get_item($path)) {
     if ($router_item['access']) {
       if (drupal_function_exists($router_item['page_callback'])) {
-        return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
+        $args = $router_item['page_arguments'] + array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+        return $router_item['page_callback']($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]);
       }
     }
     else {
@@ -458,7 +463,8 @@ function _menu_load_objects(&$item, &$ma
             }
           }
           array_unshift($args, $value);
-          $return = call_user_func_array($function, $args);
+          $args += array(NULL, NULL, NULL, NULL, NULL);
+          $return = $function($args[0], $args[1], $args[2], $args[3], $args[4]);
         }
         else {
           $return = $function($value);
Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.138
diff -u -p -r1.138 module.inc
--- includes/module.inc	14 Jan 2009 12:18:37 -0000	1.138
+++ includes/module.inc	16 Jan 2009 15:41:10 -0000
@@ -16,6 +16,10 @@ define('MODULE_IMPLEMENTS_WRITE_CACHE', 
  */
 define('MODULE_IMPLEMENTS_CLEAR_CACHE', -2);
 
+/**
+ * The maximum number of arguments a hook can accept.
+ */
+define('MODULE_HOOK_MAX_ARGUMENTS', 10);
 
 /**
  * Load all the modules that have been enabled in the system table.
@@ -487,11 +491,16 @@ function module_invoke() {
   $args = func_get_args();
   $module = $args[0];
   $hook = $args[1];
-  unset($args[0], $args[1]);
+  //unset($args[0], $args[1]);
+  array_shift($args);
+  array_shift($args);
   if (module_hook($module, $hook)) {
-    return call_user_func_array($module . '_' . $hook, $args);
+    $args += array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    $function = $module . '_' . $hook;
+    return $function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9]);
   }
 }
+
 /**
  * Invoke a hook in all enabled modules that implement it.
  *
@@ -506,12 +515,14 @@ function module_invoke() {
 function module_invoke_all() {
   $args = func_get_args();
   $hook = $args[0];
-  unset($args[0]);
+  //unset($args[0]);
+  array_shift($args);
   $return = array();
+  $args += array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
   foreach (module_implements($hook) as $module) {
     $function = $module . '_' . $hook;
     if (drupal_function_exists($function)) {
-      $result = call_user_func_array($function, $args);
+      $result = $function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9]);
       if (isset($result) && is_array($result)) {
         $return = array_merge_recursive($return, $result);
       }
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.462
diff -u -p -r1.462 theme.inc
--- includes/theme.inc	11 Jan 2009 21:23:35 -0000	1.462
+++ includes/theme.inc	16 Jan 2009 15:41:13 -0000
@@ -33,6 +33,8 @@ define('MARK_NEW', 1);
  */
 define('MARK_UPDATED', 2);
 
+define('THEME_MAX_ARGS', 10);
+
 /**
  * @} End of "Content markers".
  */
@@ -168,11 +170,12 @@ function _init_theme($theme, $base_theme
     include_once DRUPAL_ROOT . '/' . $theme->owner;
 
     $theme_engine = $theme->engine;
-    if (function_exists($theme_engine . '_init')) {
+    $function = $theme_engine . '_init';
+    if (function_exists($function)) {
       foreach ($base_theme as $base) {
-        call_user_func($theme_engine . '_init', $base);
+        $function($base);
       }
-      call_user_func($theme_engine . '_init', $theme);
+      $function($theme);
     }
   }
   else {
@@ -624,7 +627,8 @@ function theme() {
   }
   if (isset($info['function'])) {
     // The theme call is a function.
-    $output = call_user_func_array($info['function'], $args);
+    $args += array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    $output = $info['function']($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9]);
   }
   else {
     // The theme call is a template.
@@ -662,10 +666,9 @@ function theme() {
     if (isset($info['preprocess functions']) && is_array($info['preprocess functions'])) {
       // This construct ensures that we can keep a reference through
       // call_user_func_array.
-      $args = array(&$variables, $hook);
       foreach ($info['preprocess functions'] as $preprocess_function) {
         if (drupal_function_exists($preprocess_function)) {
-          call_user_func_array($preprocess_function, $args);
+          $preprocess_function($variables, $hook);
         }
       }
     }
