diff --git a/includes/common.inc b/includes/common.inc
index 262e1c5..e4a8ea0 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -5137,7 +5137,8 @@ function _drupal_bootstrap_full() {
     //   (e.g., hook_form_alter(), hook_node_view_alter(), hook_page_alter()),
     //   ahead of when rendering starts.
     menu_set_custom_theme();
-    drupal_theme_initialize();
+    // Call it with the reset option to ensure a clean initialization.
+    drupal_theme_initialize(TRUE);
     module_invoke_all('init');
   }
 }
diff --git a/includes/theme.inc b/includes/theme.inc
index ee73965..a018121 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -66,12 +66,16 @@ function _drupal_theme_access($theme) {
 
 /**
  * Initializes the theme system by loading the theme.
+ *
+ * @param bool $reset
+ *   Re-do the whole process even if the theme is already initialized.
  */
-function drupal_theme_initialize() {
+function drupal_theme_initialize($reset = FALSE) {
   global $theme, $user, $theme_key;
 
-  // If $theme is already set, assume the others are set, too, and do nothing
-  if (isset($theme)) {
+  // If $theme is already set and it's not a reset, assume the others are set,
+  // too, and do nothing.
+  if (isset($theme) && !$reset) {
     return;
   }
 
