Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.1159 diff -u -p -r1.1159 common.inc --- includes/common.inc 1 May 2010 08:12:22 -0000 1.1159 +++ includes/common.inc 3 May 2010 17:07:03 -0000 @@ -4834,6 +4834,13 @@ function drupal_pre_render_markup($eleme function drupal_render_page($page) { $main_content_display = &drupal_static('system_main_content_added', FALSE); + // menu_execute_active_handler() initializes the theme before invoking the + // page callback, but it's possible that drupal_render_page() is called for + // an error page (MENU_NOT_FOUND, MENU_ACCESS_DENIED) or during hook_init(). + // Even in these situations, the theme may implement hook_page_alter() and + // other alter hooks that get called during hook_page_build(). + drupal_theme_initialize(); + // Allow menu callbacks to return strings or arbitrary arrays to render. // If the array returned is not of #type page directly, we need to fill // in the page with defaults. Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.388 diff -u -p -r1.388 menu.inc --- includes/menu.inc 1 May 2010 08:12:22 -0000 1.388 +++ includes/menu.inc 3 May 2010 17:07:04 -0000 @@ -466,6 +466,9 @@ function menu_execute_active_handler($pa if ($router_item['include_file']) { require_once DRUPAL_ROOT . '/' . $router_item['include_file']; } + // The theme may implement alter hooks to be called during page callback + // execution prior to it otherwise initialized. + drupal_theme_initialize(); $page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']); } else {