diff --git a/src/Form/IslandoraSettingsForm.php b/src/Form/IslandoraSettingsForm.php index 9da34adf5..0ec735b75 100644 --- a/src/Form/IslandoraSettingsForm.php +++ b/src/Form/IslandoraSettingsForm.php @@ -360,17 +360,17 @@ public function submitForm(array &$form, FormStateInterface $form_state) { * Removes the Fedora Pseudo field from any entity bundles that have be unselected. * * @param array $current_config - * The current set of entity type & bundle to have the pseudo field, format {bundle}:{entity_type} + * The current set of entity types & bundles to have the pseudo field, format {bundle}:{entity_type} * @param array $new_config - * The new set of entity type & bundle to have the pseudo field, format {bundle}:{entity_type} + * The new set of entity types & bundles to have the pseudo field, format {bundle}:{entity_type} * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException * @throws \Drupal\Core\Entity\EntityStorageException */ private function updateEntityViewConfiguration(array $current_config, array $new_config) { - $cache_tags = []; $removed = array_diff($current_config, $new_config); + $added = array_diff($new_config, $current_config); $entity_view_display = $this->entityTypeManager->getStorage('entity_view_display'); // types being removed foreach ($removed as $bundle_type) { @@ -384,10 +384,12 @@ private function updateEntityViewConfiguration(array $current_config, array $new foreach ($entities as $entity) { $entity->removeComponent(self::GEMINI_PSEUDO_FIELD); $entity->save(); - $cache_tags = array_merge($cache_tags, $entity->getCacheTags()); } } - $entity_view_display->resetCache(); - Cache::invalidateTags($cache_tags); + if (count($removed) > 0 || count($added) > 0) { + // If we added or cleared a type then clear the extra_fields cache. + // @see Drupal/core/lib/Drupal/Core/Entity/EntityFieldManager::getExtraFields + Cache::invalidateTags(["entity_field_info"]); + } } }