Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.909
diff -u -p -r1.909 common.inc
--- includes/common.inc	22 May 2009 03:19:42 -0000	1.909
+++ includes/common.inc	23 May 2009 06:39:49 -0000
@@ -372,12 +372,10 @@ function drupal_not_found() {
     $return = t('The requested page could not be found.');
   }
 
-  drupal_set_page_content($return);
-  $page = element_info('page');
   // To conserve CPU and bandwidth, omit the blocks.
-  $page['#show_blocks'] = FALSE;
-
-  print drupal_render_page($page);
+  drupal_set_page_attributes(array('#show_blocks' => FALSE));
+  
+  print drupal_render_page($return);
 }
 
 /**
@@ -3206,6 +3204,33 @@ function drupal_alter($type, &$data) {
 }
 
 /**
+ * Set page attributes for displaying the page.
+ *
+ * @param $attributes
+ *   Associative array. Can have the following keys:
+ *     - #show_blocks: Suppress left/right regions if FALSE (optional).
+ *     - #show_messages: Suppress drupal_get_message() items. Used by Batch API (optional).
+ * @return
+ *   The assembled value of all page attributes in a page array structure.
+ */
+function drupal_set_page_attributes($attributes = NULL) {
+  $page_attributes = &drupal_static(__FUNCTION__, NULL);
+
+  if (empty($page_attributes)) {
+    // Fill in with default page attributes.
+    $page_attributes = element_info('page');
+  }
+
+  if (!empty($attributes)) {
+    // Make the newly provided attributes override existing ones.
+    $page_attributes = $attributes + $page_attributes;
+  }
+  else {
+    return $page_attributes;
+  }
+}
+
+/**
  * Set the main page content value for later use.
  *
  * Given the nature of the Drupal page handling, this will be called once with
@@ -3230,24 +3255,19 @@ function drupal_set_page_content($conten
 /**
  * Renders the page, including all theming.
  *
- * @param $page
- *   A string or array representing the content of a page. The array consists of
- *   the following keys:
- *   - #type: Value is always 'page'. This pushes the theming through page.tpl.php (required).
- *   - #show_blocks: A marker which suppresses left/right regions if FALSE (optional).
- *   - #show_messages: Suppress drupal_get_message() items. Used by Batch API (optional).
+ * @param $content
+ *   A string or array representing the main content of a page. The array should
+ *   be renderable via drupal_render().
  *
  * @see hook_page_alter()
  * @see element_info('page')
  */
-function drupal_render_page($page) {
-  // 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.
-  if (is_string($page) || (is_array($page) && (!isset($page['#type']) || ($page['#type'] != 'page')))) {
-    drupal_set_page_content($page);
-    $page = element_info('page');
-  }
+function drupal_render_page($content) {
+  // Set the main page content.
+  drupal_set_page_content($content);
+  // Request the possibly modified page attributes.
+  $page = drupal_set_page_attributes();
+  
   // Modules alter the $page as needed. Blocks are populated into regions like
   // 'left', 'footer', etc.
   drupal_alter('page', $page);
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.148
diff -u -p -r1.148 system.admin.inc
--- modules/system/system.admin.inc	22 May 2009 07:02:09 -0000	1.148
+++ modules/system/system.admin.inc	23 May 2009 06:39:49 -0000
@@ -1820,11 +1820,8 @@ function system_batch_page() {
   elseif (isset($output)) {
     // Force a page without blocks or messages to
     // display a list of collected messages later.
-    drupal_set_page_content($output);
-    $page = element_info('page');
-    $page['#show_blocks'] = FALSE;
-    $page['#show_messages'] = FALSE;
-    return $page;
+    drupal_set_page_attributes(array('#show_blocks' => FALSE, '#show_messages' => FALSE));
+    return $output;
   }
 }
 
