From 4aa366004461ef85cfcaaa64edc5c8b9f6bd74d7 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Fri, 17 Feb 2023 08:07:26 +0000
Subject: [PATCH] Issue #3336639 by joaopauloc.dev, joachim: Move cache
 clearing in FieldConfig::postDelete() to FieldConfigBase

---
 core/lib/Drupal/Core/Field/FieldConfigBase.php | 15 +++++++++++++++
 core/modules/field/src/Entity/FieldConfig.php  | 11 +----------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php
index bcac2379202f..fc18ccc40a0b 100644
--- a/core/lib/Drupal/Core/Field/FieldConfigBase.php
+++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php
@@ -281,6 +281,21 @@ public function postCreate(EntityStorageInterface $storage) {
     }
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function postDelete(EntityStorageInterface $storage, array $fields) {
+    // Clear the cache upfront, to refresh the results of getBundles().
+    \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
+
+    // Notify the entity storage.
+    foreach ($fields as $field) {
+      if (!$field->deleted) {
+        \Drupal::service('field_definition.listener')->onFieldDefinitionDelete($field);
+      }
+    }
+  }
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php
index 66d88deb2d3b..709c6eccd6f1 100644
--- a/core/modules/field/src/Entity/FieldConfig.php
+++ b/core/modules/field/src/Entity/FieldConfig.php
@@ -232,16 +232,7 @@ public static function preDelete(EntityStorageInterface $storage, array $fields)
    * {@inheritdoc}
    */
   public static function postDelete(EntityStorageInterface $storage, array $fields) {
-    // Clear the cache upfront, to refresh the results of getBundles().
-    \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
-
-    // Notify the entity storage.
-    foreach ($fields as $field) {
-      if (!$field->deleted) {
-        \Drupal::service('field_definition.listener')->onFieldDefinitionDelete($field);
-      }
-    }
-
+    parent::postDelete($storage, $fields);
     // If this is part of a configuration synchronization then the following
     // configuration updates are not necessary.
     $entity = reset($fields);
-- 
GitLab