function block_update_7005

Update the {block_custom}.format column.

Related topics

File

modules/block/block.install, line 411

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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.