function block_update_8003

Remove 'cache' setting.

File

core/modules/block/block.install, line 103

Code

function block_update_8003() {
    $config_factory = \Drupal::configFactory();
    foreach ($config_factory->listAll('block.block.') as $block_config_name) {
        $block = $config_factory->getEditable($block_config_name);
        // Remove the 'cache' setting.
        $settings = $block->get('settings');
        unset($settings['cache']);
        $block->set('settings', $settings);
        // Mark the resulting configuration as trusted data. This avoids issues with
        // future schema changes.
        $block->save(TRUE);
    }
    return t('Block settings updated.');
}

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