diff --git a/core/modules/aggregator/aggregator.admin.inc b/core/modules/aggregator/aggregator.admin.inc index 9b9d2be..df25c35 100644 --- a/core/modules/aggregator/aggregator.admin.inc +++ b/core/modules/aggregator/aggregator.admin.inc @@ -202,6 +202,11 @@ function aggregator_form_feed_validate($form, &$form_state) { * @todo Add delete confirmation dialog. */ function aggregator_form_feed_submit($form, &$form_state) { + // @todo Replicate this cache invalidation when these ops are separated. + // Invalidate the block cache to update aggregator feed-based derivatives. + if (module_exists('block')) { + drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + } if ($form_state['values']['op'] == t('Delete')) { $title = $form_state['values']['title']; // Unset the title. @@ -639,6 +644,11 @@ function aggregator_form_category_validate($form, &$form_state) { * @todo Add delete confirmation dialog. */ function aggregator_form_category_submit($form, &$form_state) { + // @todo Replicate this cache invalidation when these ops are separated. + // Invalidate the block cache to update aggregator category-based derivatives. + if (module_exists('block')) { + drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + } if ($form_state['values']['op'] == t('Delete')) { $title = $form_state['values']['title']; // Unset the title. diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index ceecd3f..a1e1dbf 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -371,11 +371,12 @@ function aggregator_save_category($edit) { ->condition('cid', $edit['cid']) ->execute(); // Make sure there is no active block for this category. - if (module_exists('block')) { - db_delete('block') - ->condition('module', 'aggregator') - ->condition('delta', 'category-' . $edit['cid']) - ->execute(); + $block_configs = config_get_storage_names_with_prefix('plugin.core.block'); + foreach ($block_configs as $config_id) { + $config = config($config_id); + if ($config->get('id') == 'aggregator_category_block:' . $edit['cid']) { + $config->delete(); + } } $edit['title'] = ''; $op = 'delete'; @@ -438,11 +439,12 @@ function aggregator_save_feed($edit) { ->condition('fid', $edit['fid']) ->execute(); // Make sure there is no active block for this feed. - if (module_exists('block')) { - db_delete('block') - ->condition('module', 'aggregator') - ->condition('delta', 'feed-' . $edit['fid']) - ->execute(); + $block_configs = config_get_storage_names_with_prefix('plugin.core.block'); + foreach ($block_configs as $config_id) { + $config = config($config_id); + if ($config->get('id') == 'aggregator_feed_block:' . $edit['fid']) { + $config->delete(); + } } } elseif (!empty($edit['title'])) { diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc index 736ca36..13f17ad 100644 --- a/core/modules/block/block.admin.inc +++ b/core/modules/block/block.admin.inc @@ -296,6 +296,8 @@ function block_admin_configure_submit($form, &$form_state) { $config->set($key, $value); } $config->save(); + drupal_set_message(t('The block configuration has been saved.')); + cache_invalidate_tags(array('content' => TRUE)); $form_state['redirect'] = 'admin/structure/block/list/block_plugin_ui:' . $form_state['values']['theme']; } @@ -331,7 +333,7 @@ function block_admin_block_delete_submit($form, &$form_state) { $config = config($form_state['values']['id']); $config->delete(); drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['subject']))); - $form_state['redirect'] = 'admin/structure/block/list/' . $form_state['values']['theme']; + $form_state['redirect'] = 'admin/structure/block/list/block_plugin_ui:' . $form_state['values']['theme']; } /** diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php index 3670129..8b142ef 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php @@ -95,6 +95,10 @@ public function blockSubmit($form, &$form_state) { ); drupal_write_record('block_custom', $block, !is_null($block['bid']) ? array('bid') : array()); $this->configuration['id'] = 'custom_block:' . $block['bid']; + // Invalidate the block cache to update custom block-based derivatives. + if (module_exists('block')) { + drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + } } /** diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 9c2be1e..b8f770d 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -535,11 +535,6 @@ public function submit($form, &$form_state) { if (empty($this->configuration['weight'])) { $this->configuration['weight'] = 0; } - // @todo Move this to the procedural code. - drupal_set_message(t('The block configuration has been saved.')); - // @todo Move this to the procedural code and possibly just invalidate - // the content cache rather than forcing a cache clear. - drupal_flush_all_caches(); // Perform block type-specific validation. $this->blockSubmit($form, $form_state); diff --git a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php index 49b3ee3..b7186b0 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -10,6 +10,7 @@ use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; use Drupal\Core\Plugin\Discovery\AlterDecorator; +use Drupal\Core\Plugin\Discovery\CacheDecorator; use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Core\Plugin\Mapper\ConfigMapper; @@ -29,6 +30,7 @@ public function __construct() { $this->discovery = new AnnotatedClassDiscovery('block', 'block'); $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new AlterDecorator($this->discovery, 'block'); + $this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'cache_block'); $this->factory = new DefaultFactory($this); $this->mapper = new ConfigMapper($this); } diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index 305a9e8..ff24720 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -269,6 +269,10 @@ function menu_save($menu) { )) ->execute(); menu_cache_clear_all(); + // Invalidate the block cache to update menu-based derivatives. + if (module_exists('block')) { + drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + } switch ($status) { case SAVED_NEW: @@ -335,6 +339,10 @@ function menu_delete($menu) { ->execute(); menu_cache_clear_all(); + // Invalidate the block cache to update menu-based derivatives. + if (module_exists('block')) { + drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + } module_invoke_all('menu_delete', $menu); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index e2e6038..7cbba86 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1986,15 +1986,6 @@ function theme_node_recent_content($variables) { } /** - * Implements hook_form_FORM_ID_alter() for block_add_block_form(). - * - * Adds node-type specific visibility options to add block form. - */ -function node_form_block_add_block_form_alter(&$form, &$form_state) { - //node_form_block_admin_configure_alter($form, $form_state); -} - -/** * Implements hook_form_FORM_ID_alter() for block_admin_configure(). * * Adds node-type specific visibility options to block configuration form. diff --git a/core/modules/statistics/statistics.admin.inc b/core/modules/statistics/statistics.admin.inc index 5e0e256..d1563cb 100644 --- a/core/modules/statistics/statistics.admin.inc +++ b/core/modules/statistics/statistics.admin.inc @@ -372,4 +372,9 @@ function statistics_settings_form_submit($form, &$form_state) { ->set('access_log.max_lifetime', $form_state['values']['statistics_flush_accesslog_timer']) ->set('count_content_views', $form_state['values']['statistics_count_content_views']) ->save(); + // The popular statistics block is dependent on these settings, so clear the + // block plugin definitions cache. + if (module_exists('block')) { + drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + } } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 2af25dd..f4d8404 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -742,6 +742,11 @@ function views_invalidate_cache() { // Set the menu as needed to be rebuilt. state()->set('menu_rebuild_needed', TRUE); + // Invalidate the block cache to update views block derivatives. + if (module_exists('block')) { + drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + } + // Allow modules to respond to the Views cache being cleared. module_invoke_all('views_invalidate_cache'); }