From 32bc8911b1d7345d78c17e36dbbbe64119d62e96 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 26 Mar 2010 12:45:20 +0000 Subject: [PATCH] - Patch #629902 by andypost, JohnAlbin, David_Rothstein: critical bug: theme_get_setting() should return NULL for features that are disabled in a theme. --- includes/theme.inc | 26 +++++++++++++++----------- modules/system/system.module | 29 ++++++++++++++++++----------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/includes/theme.inc b/includes/theme.inc index f5812999f08..65da03de3be 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1152,18 +1152,12 @@ function theme_get_setting($setting_name, $theme = NULL) { 'favicon_path' => '', // Use the IANA-registered MIME type for ICO files as default. 'favicon_mimetype' => 'image/vnd.microsoft.icon', - 'main_menu' => 1, - 'secondary_menu' => 1, - 'toggle_logo' => 1, - 'toggle_favicon' => 1, - 'toggle_name' => 1, - 'toggle_slogan' => 1, - 'toggle_node_user_picture' => 1, - 'toggle_comment_user_picture' => 1, - 'toggle_comment_user_verification' => 1, - 'toggle_main_menu' => 1, - 'toggle_secondary_menu' => 1, ); + // Turn on all default features. + $features = _system_default_theme_features(); + foreach ($features as $feature) { + $cache[$theme]['toggle_' . $feature] = 1; + } // Get the values for the theme-specific settings from the .info files of // the theme and all its base themes. @@ -1193,6 +1187,16 @@ function theme_get_setting($setting_name, $theme = NULL) { // Get the saved theme-specific settings from the database. $cache[$theme] = array_merge($cache[$theme], variable_get('theme_' . $theme . '_settings', array())); + // If the theme does not support a particular feature, override the global + // setting and set the value to NULL. + if (!empty($theme_object->info['features'])) { + foreach ($features as $feature) { + if (!in_array($feature, $theme_object->info['features'])) { + $cache[$theme]['toggle_' . $feature] = NULL; + } + } + } + // Generate the path to the logo image. if ($cache[$theme]['toggle_logo']) { if ($cache[$theme]['default_logo']) { diff --git a/modules/system/system.module b/modules/system/system.module index 2154d05732a..6c5cbe11986 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -2316,17 +2316,7 @@ function _system_rebuild_theme_data() { 'page_bottom' => 'Page bottom', ), 'description' => '', - 'features' => array( - 'comment_user_picture', - 'comment_user_verification', - 'favicon', - 'logo', - 'name', - 'node_user_picture', - 'slogan', - 'main_menu', - 'secondary_menu', - ), + 'features' => _system_default_theme_features(), 'screenshot' => 'screenshot.png', 'php' => DRUPAL_MINIMUM_PHP, ); @@ -2432,6 +2422,23 @@ function system_rebuild_theme_data() { return $themes; } +/** + * Returns an array of default theme features. + */ +function _system_default_theme_features() { + return array( + 'logo', + 'favicon', + 'name', + 'slogan', + 'node_user_picture', + 'comment_user_picture', + 'comment_user_verification', + 'main_menu', + 'secondary_menu', + ); +} + /** * Find all the base themes for the specified theme. *