diff --git a/includes/common.inc b/includes/common.inc
index ad2a345..b223ba4 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -5203,6 +5203,10 @@
   // Let all modules take action before the menu system handles the request.
   // We do not want this while running update.php.
   if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
+    //create global variable for theme init
+    global $drupal_theme_init;
+    $drupal_theme_init = 0;
+
     // Prior to invoking hook_init(), initialize the theme (potentially a custom
     // one for this page), so that:
     // - Modules with hook_init() implementations that call theme() or
@@ -5211,6 +5215,7 @@
     //   (e.g., hook_form_alter(), hook_node_view_alter(), hook_page_alter()),
     //   ahead of when rendering starts.
     menu_set_custom_theme();
+    $drupal_theme_init=1;
     drupal_theme_initialize();
     module_invoke_all('init');
   }
diff --git a/includes/theme.inc b/includes/theme.inc
index ed34b82..d3bfc64 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -68,6 +68,10 @@
  * Initializes the theme system by loading the theme.
  */
 function drupal_theme_initialize() {
+  global $drupal_theme_init;
+  if (!$drupal_theme_init) {
+    return;
+  }
   global $theme, $user, $theme_key;
 
   // If $theme is already set, assume the others are set, too, and do nothing
@@ -253,6 +257,10 @@
  *   class.
  */
 function theme_get_registry($complete = TRUE) {
+  global $drupal_theme_init;
+  if (!$drupal_theme_init) {
+    return array();
+  }
   // Use the advanced drupal_static() pattern, since this is called very often.
   static $drupal_static_fast;
   if (!isset($drupal_static_fast)) {
