=== modified file 'includes/common.inc'
--- includes/common.inc	2009-09-25 15:20:12 +0000
+++ includes/common.inc	2009-09-30 06:57:02 +0000
@@ -3989,6 +3989,7 @@ function drupal_system_listing($mask, $d
  *   hook_$type_alter functions.
  */
 function drupal_alter($type, &$data) {
+  global $theme, $base_theme;
   // PHP's func_get_args() always returns copies of params, not references, so
   // drupal_alter() can only manipulate data that comes in via the required first
   // param. For the edge case functions that must pass in an arbitrary number of
@@ -4016,8 +4017,19 @@ function drupal_alter($type, &$data) {
   array_shift($additional_args);
   $args = array_merge($args, $additional_args);
 
-  foreach (module_implements($type . '_alter') as $module) {
-    $function = $module . '_' . $type . '_alter';
+  drupal_theme_initialize();
+  $current_theme = new stdClass();
+  $current_theme->name = $theme;
+  $theme_bases = array_merge(array($current_theme), $base_theme);
+  $bases = module_implements($type . '_alter');
+  foreach ($theme_bases as $base) {
+    $function = $base->name . '_' . $type . '_alter';
+    if (function_exists($function)) {
+      $bases[] = $function;
+    }
+  }
+  foreach ($bases as $base) {
+    $function = $base . '_' . $type . '_alter';
     call_user_func_array($function, $args);
   }
 }

=== modified file 'includes/theme.inc'
--- includes/theme.inc	2009-09-21 06:36:54 +0000
+++ includes/theme.inc	2009-09-30 06:13:53 +0000
@@ -41,7 +41,7 @@ define('MARK_UPDATED', 2);
  * Initialize the theme system by loading the theme.
  */
 function drupal_theme_initialize() {
-  global $theme, $user, $custom_theme, $theme_key;
+  global $theme, $user, $custom_theme, $theme_key, $base_theme;
 
   // If $theme is already set, assume the others are set, too, and do nothing
   if (isset($theme)) {
@@ -69,7 +69,8 @@ function drupal_theme_initialize() {
     $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
     $ancestor = $themes[$ancestor]->base_theme;
   }
-  _drupal_theme_initialize($themes[$theme], array_reverse($base_theme));
+  $base_theme = array_reverse($base_theme);
+  _drupal_theme_initialize($themes[$theme], $base_theme);
 }
 
 /**

=== modified file 'includes/theme.maintenance.inc'
--- includes/theme.maintenance.inc	2009-09-11 13:56:56 +0000
+++ includes/theme.maintenance.inc	2009-09-30 06:45:02 +0000
@@ -15,7 +15,7 @@
  * $conf variable in order to change the maintenance theme.
  */
 function _drupal_maintenance_theme() {
-  global $theme, $theme_key;
+  global $theme, $theme_key, $base_theme;
 
   // If $theme is already set, assume the others are set too, and do nothing.
   if (isset($theme)) {
@@ -30,6 +30,7 @@ function _drupal_maintenance_theme() {
   require_once DRUPAL_ROOT . '/includes/module.inc';
   require_once DRUPAL_ROOT . '/includes/database/database.inc';
   unicode_check();
+  $base_theme = array();
 
   // Install and update pages are treated differently to prevent theming overrides.
   if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {

