From 2ad0a2c1f79b15ab74c734424a9d4a4d388028c2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 16 Jul 2010 02:37:06 +0000 Subject: - Patch #684982 by plach: audit of global language variable use. --- includes/common.inc | 17 ++++++++++------- modules/color/color.module | 4 ++-- modules/locale/locale.api.php | 4 ++-- modules/locale/locale.module | 4 ++-- modules/node/node.module | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index cd08238bd..b2cccec1e 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1551,8 +1551,8 @@ function filter_xss_bad_protocol($string, $decode = TRUE) { * Arbitrary elements may be added using the $args associative array. */ function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) { - global $language; - $langcode = $langcode ? $langcode : $language->language; + global $language_content; + $langcode = $langcode ? $langcode : $language_content->language; $output = "\n"; $output .= ' ' . check_plain($title) . "\n"; @@ -1997,8 +1997,8 @@ function format_username($account) { * - 'external': Whether the given path is an external URL. * - 'language': An optional language object. If the path being linked to is * internal to the site, $options['language'] is used to look up the alias - * for the URL. If $options['language'] is omitted, the global $language - * will be used. + * for the URL. If $options['language'] is omitted, the global + * $language_content will be used. * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on http or https * respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can @@ -5342,9 +5342,12 @@ function drupal_render_cid_parts($granularity = NULL) { global $theme, $base_root, $user; $cid_parts[] = $theme; - if (module_exists('locale')) { - global $language; - $cid_parts[] = $language->language; + // If Locale is enabled but we have only one language we do not need it as cid + // part. + if (drupal_multilingual()) { + foreach (language_types_configurable() as $language_type) { + $cid_parts[] = $GLOBALS[$language_type]->language; + } } if (!empty($granularity)) { diff --git a/modules/color/color.module b/modules/color/color.module index 01b3a432f..682518f04 100644 --- a/modules/color/color.module +++ b/modules/color/color.module @@ -73,7 +73,7 @@ function _color_theme_select_form_alter(&$form, &$form_state) { * Callback for the theme to alter the resources used. */ function _color_html_alter(&$vars) { - global $language, $theme_key; + global $theme_key; $themes = list_themes(); // Override stylesheets. @@ -102,7 +102,7 @@ function _color_html_alter(&$vars) { * Callback for the theme to alter the resources used. */ function _color_page_alter(&$vars) { - global $language, $theme_key; + global $theme_key; // Override logo. $logo = variable_get('color_' . $theme_key . '_logo'); diff --git a/modules/locale/locale.api.php b/modules/locale/locale.api.php index f39379e66..595447f1a 100644 --- a/modules/locale/locale.api.php +++ b/modules/locale/locale.api.php @@ -68,8 +68,8 @@ function hook_language_init() { function hook_language_switch_links_alter(array &$links, $type, $path) { global $language; - if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language])) { - foreach ($links[$language] as $link) { + if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language->language])) { + foreach ($links[$language->language] as $link) { $link['attributes']['class'][] = 'active-language'; } } diff --git a/modules/locale/locale.module b/modules/locale/locale.module index e122b9f93..29659ac6f 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -1000,7 +1000,7 @@ function locale_form_comment_form_alter(&$form, &$form_state, $form_id) { // If a content type has multilingual support we set the content language as // comment language. if (empty($form['language']['#value']) && locale_multilingual_node_type($form['#node']->type)) { - global $language; - $form['language']['#value'] = $language->language; + global $language_content; + $form['language']['#value'] = $language_content->language; } } diff --git a/modules/node/node.module b/modules/node/node.module index 594df7241..5e875f281 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -2354,7 +2354,7 @@ function node_block_list_alter(&$blocks) { * The link should be an absolute URL. */ function node_feed($nids = FALSE, $channel = array()) { - global $base_url, $language; + global $base_url, $language_content; if ($nids === FALSE) { $nids = db_select('node', 'n') @@ -2409,7 +2409,7 @@ function node_feed($nids = FALSE, $channel = array()) { 'title' => variable_get('site_name', 'Drupal'), 'link' => $base_url, 'description' => variable_get('feed_description', ''), - 'language' => $language->language + 'language' => $language_content->language ); $channel_extras = array_diff_key($channel, $channel_defaults); $channel = array_merge($channel_defaults, $channel); -- cgit v1.2.3