? sites/default/modules
? sites/default/settings.php
Index: modules/block/block.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v
retrieving revision 1.19
diff -u -p -r1.19 block.admin.inc
--- modules/block/block.admin.inc	16 Jul 2008 21:59:25 -0000	1.19
+++ modules/block/block.admin.inc	8 Oct 2008 16:56:30 -0000
@@ -301,17 +301,16 @@ function block_add_block_form_validate($
  * Save the new custom block.
  */
 function block_add_block_form_submit($form, &$form_state) {
-  db_query("INSERT INTO {boxes} (body, info, format) VALUES ('%s', '%s', %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['format']);
-  $delta = db_last_insert_id('boxes', 'bid');
+  drupal_write_record('boxes', $form_state['values']);
 
   foreach (list_themes() as $key => $theme) {
     if ($theme->status) {
-      db_query("INSERT INTO {blocks} (visibility, pages, custom, title, module, theme, status, weight, delta, cache) VALUES(%d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE);
+      db_query("INSERT INTO {blocks} (visibility, pages, custom, title, module, theme, status, weight, delta, cache) VALUES(%d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $form_state['values']['bid'], BLOCK_NO_CACHE);
     }
   }
 
   foreach (array_filter($form_state['values']['roles']) as $rid) {
-    db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $delta);
+    db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $form_state['values']['bid']);
   }
 
   drupal_set_message(t('The block has been created.'));
Index: modules/block/block.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.install,v
retrieving revision 1.11
diff -u -p -r1.11 block.install
--- modules/block/block.install	15 May 2008 21:30:02 -0000	1.11
+++ modules/block/block.install	8 Oct 2008 16:56:31 -0000
@@ -136,7 +136,7 @@ function block_schema() {
         'description' => t("The block's {blocks}.bid."),
       ),
       'body' => array(
-        'type' => 'text',
+        'type' => 'blob',
         'not null' => FALSE,
         'size' => 'big',
         'description' => t('Block contents.'),
@@ -167,3 +167,23 @@ function block_schema() {
 
   return $schema;
 }
+
+/**
+ * @defgroup updates-6.x-to-7.x Block updates from 6.x to 7.x
+ * @{
+ */
+
+/**
+ * Remap {boxes}.body as BLOB type.
+ */
+function block_update_7000() {
+  $ret = array();
+  db_change_field($ret, 'boxes', 'body', 'body', array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'));
+
+  return $ret;
+}
+
+/**
+ * @} End of "defgroup updates-6.x-to-7.x"
+ * The next series of updates should start at 8000.
+ */
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.311
diff -u -p -r1.311 block.module
--- modules/block/block.module	6 Oct 2008 11:30:10 -0000	1.311
+++ modules/block/block.module	8 Oct 2008 16:56:31 -0000
@@ -329,7 +329,11 @@ function block_box_save($edit, $delta) {
     $edit['body_format'] = FILTER_FORMAT_DEFAULT;
   }
 
-  db_query("UPDATE {boxes} SET body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['body'], $edit['info'], $edit['body_format'], $delta);
+  $edit += array(
+    'bid' => $delta,
+    'format' => $edit['body_format']
+  );
+  drupal_write_record('boxes', $edit, 'bid');
 
   return TRUE;
 }
