diff --git a/includes/form.inc b/includes/form.inc index 0c50e190b1da0653c3e3eacc74e95987bf141a12..59ed6517af4939e91ad66d021c09f77cf3445f8d 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -929,38 +929,14 @@ function drupal_prepare_form($form_id, &$form, &$form_state) { } } - // Check theme functions for this form. + // If no #theme has been set, automatically apply theme suggestions. // theme_form() itself is in #theme_wrappers and not #theme. Therefore, the // #theme function only has to care for rendering the inner form elements, // not the form itself. - drupal_theme_initialize(); - $registry = theme_get_registry(); - // If #theme has been set, check whether the theme function(s) exist, or - // remove the suggestion(s), so drupal_render() renders the children. - if (isset($form['#theme'])) { - if (is_array($form['#theme'])) { - foreach ($form['#theme'] as $key => $suggestion) { - if (!isset($registry[$suggestion])) { - unset($form['#theme'][$key]); - } - } - if (empty($form['#theme'])) { - unset($form['#theme']); - } - } - else { - if (!isset($registry[$form['#theme']])) { - unset($form['#theme']); - } - } - } - // Only try to auto-suggest theme functions, if #theme has not been set. - else { - if (isset($registry[$form_id])) { - $form['#theme'] = $form_id; - } - elseif (isset($form_state['build_info']['base_form_id']) && isset($registry[$form_state['build_info']['base_form_id']])) { - $form['#theme'] = $form_state['build_info']['base_form_id']; + if (!isset($form['#theme'])) { + $form['#theme'] = array($form_id); + if (isset($form_state['build_info']['base_form_id'])) { + $form['#theme'][] = $form_state['build_info']['base_form_id']; } } diff --git a/includes/install.core.inc b/includes/install.core.inc index a334f7bb3d6e595a9d3e6906707c3b5b18ed0444..906a48e43558a541c0885488dfca358e9a6ecd38 100644 --- a/includes/install.core.inc +++ b/includes/install.core.inc @@ -275,12 +275,12 @@ function install_begin_request(&$install_state) { require_once DRUPAL_ROOT . '/includes/cache-install.inc'; $conf['cache_default_class'] = 'DrupalFakeCache'; - // Prepare for themed output, if necessary. We need to run this at the - // beginning of the page request to avoid a different theme accidentally - // getting set. - if ($install_state['interactive']) { - drupal_maintenance_theme(); - } + // Prepare for themed output. We need to run this at the beginning of the + // page request to avoid a different theme accidentally getting set. (We also + // need to run it even in the case of command-line installations, to prevent + // any code in the installer that happens to initialize the theme system from + // accessing the database before it is set up yet.) + drupal_maintenance_theme(); // Check existing settings.php. $install_state['settings_verified'] = install_verify_settings(); diff --git a/includes/theme.inc b/includes/theme.inc index 5a7b591f871ed4dd75c4a3f3190f5574bd6234b0..87c8dba5094cf4a2b6172669cab919675632f981 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -768,7 +768,11 @@ function theme($hook, $variables = array()) { } } if (!isset($hooks[$hook])) { - watchdog('theme', 'Theme key "@key" not found.', array('@key' => $hook), WATCHDOG_WARNING); + // Only log a message when not trying theme suggestions ($hook being an + // array). + if (!isset($candidate)) { + watchdog('theme', 'Theme key "@key" not found.', array('@key' => $hook), WATCHDOG_WARNING); + } return ''; } }