### Eclipse Workspace Patch 1.0
#P drupal_test_7
Index: modules/block/block.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v
retrieving revision 1.17
diff -u -r1.17 block.admin.inc
--- modules/block/block.admin.inc	15 May 2008 21:30:02 -0000	1.17
+++ modules/block/block.admin.inc	1 Jul 2008 00:59:07 -0000
@@ -14,9 +14,10 @@
 
   // If non-default theme configuration has been selected, set the custom theme.
   $custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
+  init_theme();
 
-  // Fetch and sort blocks.
-  $blocks = _block_rehash();
+  // Fetch and sort blocks
+  $blocks = _block_rehash($custom_theme);
   usort($blocks, '_block_compare');
 
   return drupal_get_form('block_admin_display_form', $blocks, $theme);
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.307
diff -u -r1.307 block.module
--- modules/block/block.module	26 May 2008 17:12:54 -0000	1.307
+++ modules/block/block.module	1 Jul 2008 00:59:07 -0000
@@ -218,12 +218,24 @@
  * @return
  *   Blocks currently exported by modules.
  */
-function _block_rehash() {
+function _block_rehash($theme = NULL) {
   global $theme_key;
 
-  init_theme();
+  if ($theme == '**ALL**') {
+    $blocks = array();
+    foreach (list_themes() as $theme) {
+      if ($theme->status || $theme->name == variable_get('admin_theme', '0')) {
+        $blocks[$theme->name] = _block_rehash($theme->name);
+      }
+    }
+    return $blocks;
+  }
 
-  $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key);
+  if (empty($theme)) {
+    $theme = $theme_key;
+  }
+
+  $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme);
   $old_blocks = array();
   while ($old_block = db_fetch_array($result)) {
     $old_blocks[$old_block['module']][$old_block['delta']] = $old_block;
@@ -231,7 +243,7 @@
 
   $blocks = array();
   // Valid region names for the theme.
-  $regions = system_region_list($theme_key);
+  $regions = system_region_list($theme);
 
   foreach (module_list() as $module) {
     $module_blocks = module_invoke($module, 'block', 'list');
@@ -241,7 +253,7 @@
           // If it's a new block, add identifiers.
           $block['module'] = $module;
           $block['delta']  = $delta;
-          $block['theme']  = $theme_key;
+          $block['theme']  = $theme;
           if (!isset($block['pages'])) {
             // {block}.pages is type 'text', so it cannot have a
             // default value, and not null, so we need to provide
@@ -256,11 +268,16 @@
           $blocks[] = $block;
         }
         else {
-          // If it's an existing block, database settings should overwrite
-          // the code. But aside from 'info' everything that's definable in
-          // code is stored in the database and we do not store 'info', so we
-          // do not need to update the database here.
-          // Add 'info' to this block.
+          // For existing block, database settings should overwrite the code,
+          // except for possible changes in the cache mode.
+          if ((!isset($block['cache']) && $old_blocks[$module][$delta]['cache'] != BLOCK_CACHE_PER_ROLE) || (isset($block['cache']) && $old_blocks[$module][$delta]['cache'] != $block['cache'])) {
+            $updated_block = array('cache' => isset($block['cache']) ? $block['cache'] : BLOCK_CACHE_PER_ROLE, 'module' => $module, 'delta' => $delta, 'theme' => $theme);
+            drupal_write_record('blocks', $updated_block, array('module', 'delta', 'theme'));
+            cache_clear_all("$module:$delta:", 'cache_block', TRUE);
+            $old_blocks[$module][$delta]['cache'] = $updated_block['cache'];
+          }
+          // 'info' is the only thing that's definable in code but not stored
+          // in the database.
           $old_blocks[$module][$delta]['info'] = $block['info'];
           // If the region name does not exist, disable the block and assign it to none.
           if (!empty($old_blocks[$module][$delta]['region']) && !isset($regions[$old_blocks[$module][$delta]['region']])) {
@@ -283,7 +300,7 @@
   // Remove blocks that are no longer defined by the code from the database.
   foreach ($old_blocks as $module => $old_module_blocks) {
     foreach ($old_module_blocks as $delta => $block) {
-      db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme_key);
+      db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme);
     }
   }
   return $blocks;
