summaryrefslogtreecommitdiff
path: root/includes/theme.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/theme.inc')
-rw-r--r--includes/theme.inc8
1 files changed, 8 insertions, 0 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index b54f0bc13..2e5c691bd 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -764,6 +764,14 @@ function list_themes($refresh = FALSE) {
*/
function theme($hook, $variables = array()) {
static $hooks = NULL;
+
+ // If called before all modules are loaded, we do not necessarily have a full
+ // theme registry to work with, and therefore cannot process the theme
+ // request properly. See also _theme_load_registry().
+ if (!module_load_all(NULL) && !defined('MAINTENANCE_MODE')) {
+ throw new Exception(t('theme() may not be called until all modules are loaded.'));
+ }
+
if (!isset($hooks)) {
drupal_theme_initialize();
$hooks = theme_get_registry();