diff --git a/core/includes/common.inc b/core/includes/common.inc
index ed359612c33849ad285c8caf26848ce1b2abbb1b..2bee0e5547e39e9255a5b3c7596b71f80c137a71 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -558,7 +558,9 @@ function drupal_flush_all_caches($kernel = NULL) {
   // Wipe the Twig PHP Storage cache.
   \Drupal::service('twig')->invalidate();
 
-  // Rebuild theme data that is stored in state.
+  // Rebuild profile, profile, theme_engine and theme data.
+  \Drupal::service('extension.list.profile')->reset();
+  \Drupal::service('extension.list.theme_engine')->reset();
   \Drupal::service('theme_handler')->refreshInfo();
   // In case the active theme gets requested later in the same request we need
   // to reset the theme manager.