diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index dafed5d..5ed72ef 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -446,14 +446,21 @@ public function onDependencyRemoval(array $dependencies) { $changed = parent::onDependencyRemoval($dependencies); foreach ($dependencies['config'] as $entity) { if ($entity->getEntityTypeId() == 'field_storage_config') { - $executable = $this->getExecutable(); - foreach ($this->get('display') as $display_id => $display) { - $executable->setDisplay($display_id); - if ($executable->getDisplay()->usesFields()) { - $fields = $executable->getDisplay()->getOption('fields'); - unset($fields[$entity->getName()]); - $executable->getDisplay()->setOption('fields', $fields); - $changed = TRUE; + foreach (array_keys($this->get('display')) as $display_id) { + $display = &$this->getDisplay($display_id); + // Check if the field is being used on each handler type and if + // necessary remove it. + foreach (Views::getHandlerTypes() as $handler_type) { + $handler_type = $handler_type['plural']; + if (!isset($display['display_options'][$handler_type])) { + continue; + } + foreach ($display['display_options'][$handler_type] as $id => $handler_config) { + if (strpos($id, $entity->getName()) === 0) { + unset($display['display_options'][$handler_type][$id]); + $changed = TRUE; + } + } } } }