? block.patch
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.403
diff -u -p -r1.403 menu.inc
--- includes/menu.inc	19 Jul 2010 21:57:49 -0000	1.403
+++ includes/menu.inc	27 Jul 2010 05:46:08 -0000
@@ -3212,6 +3212,13 @@ function _menu_router_build($callbacks) 
             $item['access arguments'] = $parent['access arguments'];
           }
         }
+        // If load arguments are not found for a default local task we use the
+        // load arguments from the parent, since we expect them to be
+        // identical. In all other cases, the load arguments must be specified.
+        if (($item['type'] == MENU_DEFAULT_LOCAL_TASK) && !isset($item['load arguments']) && isset($parent['load arguments'])) {
+          $item['load arguments'] = $parent['load arguments'];
+          $item['load_functions'] = $parent['load_functions'];
+        }
         // Same for page callbacks.
         if (!isset($item['page callback']) && isset($parent['page callback'])) {
           $item['page callback'] = $parent['page callback'];
Index: modules/block/block.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v
retrieving revision 1.84
diff -u -p -r1.84 block.admin.inc
--- modules/block/block.admin.inc	24 Jul 2010 17:53:55 -0000	1.84
+++ modules/block/block.admin.inc	27 Jul 2010 05:46:08 -0000
@@ -198,17 +198,14 @@ function _block_compare($a, $b) {
  *
  * Also used by block_add_block_form() for adding a new custom block.
  *
- * @param $module
- *   Name of the module that implements the block to be configured.
- * @param $delta
- *   Unique ID of the block within the context of $module.
+ * @param $block
+ *   The block object for the block to be configured.
  *
  * @see block_admin_configure_validate()
  * @see block_admin_configure_submit()
  * @ingroup forms
  */
-function block_admin_configure($form, &$form_state, $module, $delta) {
-  $block = block_load($module, $delta);
+function block_admin_configure($form, &$form_state, $block) {
   $form['module'] = array(
     '#type' => 'value',
     '#value' => $block->module,
@@ -464,7 +461,12 @@ function block_admin_configure_submit($f
  * @ingroup forms
  */
 function block_add_block_form($form, &$form_state) {
-  return block_admin_configure($form, $form_state, 'block', NULL);
+  // The block does not exist yet, so pass in a stub block object.
+  $block = new stdClass();
+  $block->module = 'block';
+  $block->delta = NULL;
+
+  return block_admin_configure($form, $form_state, $block);
 }
 
 /**
@@ -557,11 +559,9 @@ function block_add_block_form_submit($fo
  *
  * @see block_custom_block_delete_submit()
  */
-function block_custom_block_delete($form, &$form_state, $module, $delta) {
-  $block = block_load($module, $delta);
-  $custom_block = block_custom_block_get($block->delta);
+function block_custom_block_delete($form, &$form_state, $custom_block) {
   $form['info'] = array('#type' => 'hidden', '#value' => $custom_block['info'] ? $custom_block['info'] : $custom_block['title']);
-  $form['bid'] = array('#type' => 'hidden', '#value' => $block->delta);
+  $form['bid'] = array('#type' => 'hidden', '#value' => $custom_block['bid']);
 
   return confirm_form($form, t('Are you sure you want to delete the block %name?', array('%name' => $custom_block['info'])), 'admin/structure/block', '', t('Delete'), t('Cancel'));
 }
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.426
diff -u -p -r1.426 block.module
--- modules/block/block.module	8 Jul 2010 03:41:27 -0000	1.426
+++ modules/block/block.module	27 Jul 2010 05:46:09 -0000
@@ -118,23 +118,25 @@ function block_menu() {
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
   );
-  $items['admin/structure/block/manage/%/%'] = array(
+  $items['admin/structure/block/manage/%block/%'] = array(
     'title' => 'Configure block',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('block_admin_configure', 4, 5),
     'access arguments' => array('administer blocks'),
+    'load arguments' => array(5),
     'file' => 'block.admin.inc',
   );
-  $items['admin/structure/block/manage/%/%/configure'] = array(
+  $items['admin/structure/block/manage/%block/%/configure'] = array(
     'title' => 'Configure block',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'context' => MENU_CONTEXT_INLINE,
   );
-  $items['admin/structure/block/manage/%/%/delete'] = array(
+  $items['admin/structure/block/manage/%/%block_custom_block/delete'] = array(
     'title' => 'Delete block',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('block_custom_block_delete', 4, 5),
+    'page arguments' => array('block_custom_block_delete', 5),
     'access arguments' => array('administer blocks'),
+    'load arguments' => array(4),
     'type' => MENU_LOCAL_TASK,
     'context' => MENU_CONTEXT_NONE,
     'file' => 'block.admin.inc',
@@ -226,7 +228,7 @@ function block_block_info() {
 function block_block_configure($delta = 0) {
   $custom_block = array('format' => filter_default_format());
   if ($delta) {
-    $custom_block = block_custom_block_get($delta);
+    $custom_block = block_custom_block_load($delta);
   }
   return block_custom_block_form($custom_block);
 }
@@ -463,6 +465,9 @@ function _block_rehash($theme = NULL) {
  *
  * @param $bid
  *   ID of the block to get information for.
+ * @param $module
+ *   The module that defines the block. If this is anything besides 'block',
+ *   this function will return FALSE, because the block would not be custom.
  * @return
  *   Associative array of information stored in the database for this block.
  *   Array keys:
@@ -471,7 +476,10 @@ function _block_rehash($theme = NULL) {
  *   - body: Block contents.
  *   - format: Filter ID of the filter format for the body.
  */
-function block_custom_block_get($bid) {
+function block_custom_block_load($bid, $module = 'block') {
+  if ($module != 'block') {
+    return FALSE;
+  }
   return db_query("SELECT * FROM {block_custom} WHERE bid = :bid", array(':bid' => $bid))->fetchAssoc();
 }
 
@@ -658,14 +666,6 @@ function block_load($module, $delta) {
     $block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta', array(':module' => $module, ':delta' => $delta))->fetchObject();
   }
 
-  // If the block does not exist in the database yet return a stub block
-  // object.
-  if (empty($block)) {
-    $block = new stdClass();
-    $block->module = $module;
-    $block->delta = $delta;
-  }
-
   return $block;
 }
 
Index: modules/statistics/statistics.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.test,v
retrieving revision 1.20
diff -u -p -r1.20 statistics.test
--- modules/statistics/statistics.test	8 Jul 2010 03:41:27 -0000	1.20
+++ modules/statistics/statistics.test	27 Jul 2010 05:46:11 -0000
@@ -164,7 +164,9 @@ class StatisticsReportsTestCase extends 
     $this->drupalGet('node/' . $node->nid);
 
     // Configure and save the block.
-    $block = block_load('statistics', 'popular');
+    $block = new stdClass();
+    $block->module = 'statistics';
+    $block->delta = 'popular';
     $block->theme = variable_get('theme_default', 'bartik');
     $block->status = 1;
     $block->pages = '';
