diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index 6a3dd0c..577951a 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -379,4 +379,29 @@ function testBlockRehash() { $config = $instance->getConfig(); $this->assertEqual($config['cache'], DRUPAL_NO_CACHE, "Test block's database entry updated to DRUPAL_NO_CACHE."); } + + /** + * Test disabled blocks. + */ + function testBlockModuleDisable() { + module_enable(array('block_test')); + $this->assertTrue(module_exists('block_test'), 'Test block module enabled.'); + + // Clear the block cache to load the block_test module's block definitions. + $manager = $this->container->get('plugin.manager.block'); + $manager->clearCachedDefinitions(); + + // Add a test block. + $plugin = $manager->getDefinition('test_cache'); + $block = array(); + $block['id'] = 'test_cache'; + $block['machine_name'] = $this->randomName(8); + $block['theme'] = variable_get('theme_default', 'stark'); + $block['region'] = 'header'; + $this->drupalPost('admin/structure/block/manage/' . $block['id'] . '/' . $block['theme'], array('machine_name' => $block['machine_name'], 'region' => $block['region']), t('Save block')); + + module_disable(array('block_test'), FALSE); + $this->drupalGet('admin/structure/block'); + $this->assertResponse(200); + } } diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc index a62ad2e..59c871f 100644 --- a/core/modules/field/field.crud.inc +++ b/core/modules/field/field.crud.inc @@ -535,12 +535,15 @@ function field_create_instance(&$instance) { * Read-only ID properties are assigned automatically. Any other properties * properties specified in $instance overwrite the existing values for * the instance. + * @param $reset + * An optional boolean to control whether or not the field cache should + + be refreshed. Defaults to TRUE. * * @throws Drupal\field\FieldException * * @see field_create_instance() */ -function field_update_instance($instance) { +function field_update_instance($instance, $reset = TRUE) { // Check that the specified field exists. $field = field_read_field($instance['field_name']); if (empty($field)) { @@ -560,7 +563,9 @@ function field_update_instance($instance) { _field_write_instance($instance, TRUE); // Clear caches. - field_cache_clear(); + if ($reset) { + field_cache_clear(); + } module_invoke_all('field_update_instance', $instance, $prior_instance); } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php index a977df9..6ef9b0a 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -549,7 +549,9 @@ public function submit(array $form, array &$form_state) { if (in_array($key, $form['#fields'])) { $instance = field_read_instance($this->entity_type, $key, $this->bundle); $instance['widget']['weight'] = $values['weight']; - field_update_instance($instance); + // Field cache will be cleared when the field instance is created, and + // field cache should not be cleared N+1 times. + field_update_instance($instance, FALSE); } elseif (in_array($key, $form['#extra'])) { $bundle_settings['extra_fields']['form'][$key]['weight'] = $values['weight'];