Index: includes/update.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/update.inc,v retrieving revision 1.13 diff -u -F^f -u -F^f -r1.13 update.inc --- includes/update.inc 13 Oct 2009 05:26:57 -0000 1.13 +++ includes/update.inc 16 Oct 2009 19:33:19 -0000 @@ -104,6 +104,36 @@ function update_prepare_d7_bootstrap() { } /** + * A helper function that modules can use to assist with the transformation + * from numeric block deltas to string block deltas during the 6.x -> 7.x + * upgrade. This function should be removed in 8.x. + * + * @param $module + * The name of the module providing the blocks. + * @param $data + * An associative array mapping the old block deltas to the new block deltas. + * Keys are the old numeric deltas, values are the new string deltas. + * Example: + * array( + * 0 => 'mymodule-block-1', + * 1 => 'mymodule-block-2', + * ); + */ +function update_fix_block_deltas($module, $data) { + // Check to make sure the module exists, and we have an array of data to work + // with. + if (module_exists($module) && is_array($data)) { + foreach ($data as $old_delta => $new_delta) { + db_update('blocks') + ->fields(array('delta' => $new_delta)) + ->condition('module', $module) + ->condition('delta', $old_delta) + ->execute(); + } + } +} + +/** * Perform Drupal 6.x to 7.x updates that are required for update.php * to function properly. *