Index: modules/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block.module,v
retrieving revision 1.178
diff -u -r1.178 block.module
--- modules/block.module	25 Aug 2005 21:14:16 -0000	1.178
+++ modules/block.module	9 Sep 2005 20:07:19 -0000
@@ -471,10 +471,12 @@
 
   static $blocks = array();
 
-  if (!isset($blocks[$region])) {
-    $blocks[$region] = array();
-    $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 AND region = '%s' ORDER BY weight, module", $theme_key, $region);
+  if (!count($blocks)) {
+    $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 ORDER BY region, weight, module", $theme_key, $region);
     while ($block = db_fetch_array($result)) {
+      if(!isset($blocks[$block->region])) {
+        $blocks[$block->region] = array();
+      }
       // Use the user's block visibility setting, if necessary
       if ($block['custom'] != 0) {
         if ($user->uid && isset($user->block[$block['module']][$block['delta']])) {
@@ -517,6 +519,10 @@
       }
     }
   }
+  // Create an empty array if there were no entries
+  if(!isset($blocks[$region])) {
+    $blocks[$region] = Array();
+  }
   return $blocks[$region];
 }
