Index: sections.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sections/sections.module,v
retrieving revision 1.16.2.27
diff -u -p -r1.16.2.27 sections.module
--- sections.module	20 Dec 2009 21:24:12 -0000	1.16.2.27
+++ sections.module	2 Mar 2010 16:02:57 -0000
@@ -32,9 +32,22 @@ function sections_perm() {
  * Implementation of hook_menu().
  */
 function sections_menu($may_cache) {
-  // Never *ever* use t() with %name in hook_menu OR init_theme() get's fired for theme_placeholder
-  // by theme_get_function function and theme switch will fail for anonymous users in cached mode
-  // with subthemes!
+  // This code must be ran very early in page request to ensure that the theme has not been initalized yet.
+  // It's possible that other modules which piggyback on hook_menu will inadvertantly initialize the theme system.
+  // This is an ugly fix, but so doing this kind of stuff in hook_menu().
+  static $first = TRUE;
+  if ($first &&  $section = sections_in_section()) {
+    // only switch to custom theme if theme is active, to prohibit a destroyed site
+    foreach (list_themes() as $key => $theme) {
+      if ($theme->status == 1 && $theme->name == $section->theme) {
+        global $custom_theme;
+        $custom_theme = $section->theme;
+        init_theme();
+      }
+    }
+
+    $first = FALSE;
+  }
 
   // admin/build/sections/ show the summary
   // admin/build/sections/list show the summary
@@ -88,17 +101,6 @@ function sections_menu($may_cache) {
         'type' => MENU_CALLBACK
       );
     }
-
-  }
-  else if ($section = sections_in_section()) {
-    // only switch to custom theme if theme is active, to prohibit a destroyed site
-    foreach (list_themes() as $key => $theme) {
-      if ($theme->status == 1 && $theme->name == $section->theme) {
-        global $custom_theme;
-        $custom_theme = $section->theme;
-        init_theme();
-      }
-    }
   }
 
   return $items;
