function block_update_7005

7.x block.install block_update_7005()

Update the {block_custom}.format column.

Related topics

File

drupal-7.x/modules/block/block.install, line 411
Install, update and uninstall functions for the block module.

Code

function block_update_7005() {
  // For an explanation of these updates, see the code comments in
  // user_update_7010().
  db_change_field('block_custom', 'format', 'format', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => FALSE,
    'description' => 'The {filter_format}.format of the block body.',
  ));
  db_update('block_custom')
    ->fields(array('format' => NULL))
    ->condition('body', '')
    ->condition('format', 0)
    ->execute();
  $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
  $default_format = variable_get('filter_default_format', 1);
  db_update('block_custom')
    ->fields(array('format' => $default_format))
    ->isNotNull('format')
    ->condition('format', $existing_formats, 'NOT IN')
    ->execute();
}