Commit 57ab8a54 authored by Dries's avatar Dries

- Patch #1510686 by cosmicdreams, vasi1186, webflo, disasm: replace remaining...

- Patch #1510686 by cosmicdreams, vasi1186, webflo, disasm: replace remaining references to global () with drupal_container().
parent 5b8960df
......@@ -2620,7 +2620,6 @@ function drupal_language_initialize() {
// @todo Temporary backwards compatibility for code still using globals.
// Remove after these issues:
// - $language_interface: http://drupal.org/node/1510686
// - $language_url: http://drupal.org/node/1512310
foreach ($types as $type) {
$GLOBALS[$type] = $container->get($type);
......
......@@ -1095,7 +1095,6 @@ function menu_tree_output($tree) {
*/
function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
$tree = &drupal_static(__FUNCTION__, array());
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Use $mlid as a flag for whether the data being loaded is for the whole tree.
......@@ -1363,7 +1362,6 @@ function menu_build_tree($menu_name, array $parameters = array()) {
function _menu_build_tree($menu_name, array $parameters = array()) {
// Static cache of already built menu trees.
$trees = &drupal_static(__FUNCTION__, array());
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Build the cache id; sort parents to prevent duplicate storage and remove
......
......@@ -2788,6 +2788,12 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
* @see maintenance-page.tpl.php
*/
function template_preprocess_maintenance_page(&$variables) {
global $theme;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Retrieve the theme data to list all available regions.
$theme_data = list_themes();
$regions = $theme_data[$theme]->info['regions'];
// Add favicon
if (theme_get_setting('toggle_favicon')) {
$favicon = theme_get_setting('favicon');
......@@ -2795,11 +2801,6 @@ function template_preprocess_maintenance_page(&$variables) {
drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon), 'type' => $type));
}
global $theme;
// Retrieve the theme data to list all available regions.
$theme_data = list_themes();
$regions = $theme_data[$theme]->info['regions'];
// Get all region content set with drupal_add_region_content().
foreach (array_keys($regions) as $region) {
// Assign region to a region variable.
......@@ -2830,8 +2831,6 @@ function template_preprocess_maintenance_page(&$variables) {
}
}
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$variables['head_title_array'] = $head_title;
$variables['head_title'] = implode(' | ', $head_title);
$variables['base_path'] = base_path();
......
......@@ -328,7 +328,8 @@ function hook_block_view_MODULE_DELTA_alter(&$data, $block) {
* An array of $blocks, keyed by the block ID.
*/
function hook_block_list_alter(&$blocks) {
global $language_interface, $theme_key;
global $theme_key;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// This example shows how to achieve language specific visibility setting for
// blocks.
......
......@@ -1224,7 +1224,8 @@ function book_toc($bid, $depth_limit, $exclude = array()) {
* @see book-export-html.tpl.php
*/
function template_preprocess_book_export_html(&$variables) {
global $base_url, $language_interface;
global $base_url;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$variables['title'] = check_plain($variables['title']);
$variables['base_url'] = $base_url;
......
......@@ -23,7 +23,7 @@ public static function getInfo() {
* Creates a comment, then tests the tokens generated from it.
*/
function testCommentTokenReplacement() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
......
......@@ -129,7 +129,8 @@ function contact_site_form_validate($form, &$form_state) {
* @see contact_site_form_validate()
*/
function contact_site_form_submit($form, &$form_state) {
global $user, $language_interface;
global $user;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$values = $form_state['values'];
$values['sender'] = $user;
......@@ -250,7 +251,8 @@ function contact_personal_form($form, &$form_state, $recipient) {
* @see contact_personal_form_validate()
*/
function contact_personal_form_submit($form, &$form_state) {
global $user, $language_interface;
global $user;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$values = $form_state['values'];
$values['sender'] = $user;
......
......@@ -45,7 +45,7 @@ function entity_modules_disabled() {
* @see hook_entity_info_alter()
*/
function entity_get_info($entity_type = NULL) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......
......@@ -67,7 +67,7 @@ function field_info_cache_clear() {
* @see _field_info_collate_types_reset()
*/
function _field_info_collate_types() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......
......@@ -1079,7 +1079,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
* Creates a file, then tests the tokens generated from it.
*/
function testFileTokenReplacement() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
......
......@@ -399,7 +399,7 @@ function filter_modules_disabled($modules) {
* @see filter_formats_reset()
*/
function filter_formats($account = NULL) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$formats = &drupal_static(__FUNCTION__, array());
// All available formats are cached for performance.
......
......@@ -923,7 +923,7 @@ function image_style_path($style_name, $uri) {
* @see image_effect_definition_load()
*/
function image_effect_definitions() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// hook_image_effect_info() includes translated strings, so each language is
// cached separately.
......
......@@ -234,7 +234,7 @@ function language_delete($langcode) {
* and checks to see if a related right to left CSS file should be included.
*/
function language_css_alter(&$css) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// If the current language is RTL, add the CSS file with the RTL overrides.
if ($language_interface->direction == LANGUAGE_RTL) {
......
......@@ -190,8 +190,8 @@ function locale_menu() {
* Initialize date formats according to the user's current locale.
*/
function locale_init() {
global $conf, $language_interface;
global $conf;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// For each date type (e.g. long, short), get the localized date format
// for the user's current language and override the default setting for it
// in $conf. This should happen on all pages except the date and time formats
......@@ -389,7 +389,7 @@ function locale_language_delete($language) {
* Language code to use for the lookup.
*/
function locale($string = NULL, $context = NULL, $langcode = NULL) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......@@ -502,7 +502,7 @@ function locale_reset() {
* plural formula.
*/
function locale_get_plural($count, $langcode = NULL) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Used to locally cache the plural formulas for all languages.
$plural_formulas = &drupal_static(__FUNCTION__, array());
......@@ -588,7 +588,7 @@ function locale_system_update($components) {
* file if necessary, and adds it to the page.
*/
function locale_js_alter(&$javascript) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$dir = 'public://' . variable_get('locale_js_directory', 'languages');
$parsed = variable_get('javascript_parsed', array());
......@@ -648,7 +648,7 @@ function locale_js_alter(&$javascript) {
*/
function locale_library_info_alter(&$libraries, $module) {
if ($module == 'system' && isset($libraries['ui.datepicker'])) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// locale.datepicker.js should be added in the JS_LIBRARY group, so that
// this attach behavior will execute early. JS_LIBRARY is the default for
// hook_library_info_alter(), thus does not have to be specified explicitly.
......@@ -792,7 +792,7 @@ function locale_form_system_file_system_settings_alter(&$form, $form_state) {
*/
function locale_preprocess_node(&$variables) {
if ($variables['langcode'] != LANGUAGE_NOT_SPECIFIED) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$node_language = language_load($variables['langcode']);
if ($node_language->langcode != $language_interface->langcode) {
......
......@@ -83,7 +83,7 @@ function openid_redirect_http($url, $message) {
* Creates a js auto-submit redirect for (for the 2.x protocol)
*/
function openid_redirect($url, $message) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
$output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $language_interface->langcode . '" lang="' . $language_interface->langcode . '">' . "\n";
......
......@@ -23,7 +23,7 @@ public static function getInfo() {
* Creates a poll, then tests the tokens generated from it.
*/
function testPollTokenReplacement() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Craete a poll with three choices.
$title = $this->randomName();
......
......@@ -104,7 +104,7 @@ function template_preprocess_search_results(&$variables) {
* @see search-result.tpl.php
*/
function template_preprocess_search_result(&$variables) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$result = $variables['result'];
$variables['url'] = check_url($result['link']);
......
......@@ -608,7 +608,8 @@ protected function changeDatabasePrefix() {
* @see TestBase::tearDown()
*/
protected function prepareEnvironment() {
global $user, $language_interface, $conf;
global $user, $conf;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Backup current in-memory configuration.
$this->originalConf = $conf;
......@@ -672,7 +673,8 @@ protected function prepareEnvironment() {
* @see TestBase::prepareEnvironment()
*/
protected function tearDown() {
global $user, $language_interface, $conf;
global $user, $conf;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// In case a fatal error occurred that was not in the test process read the
// log to pick up any fatal errors.
......
......@@ -578,7 +578,8 @@ protected function drupalLogout() {
* @see Drupal\simpletest\WebTestBase::prepareEnvironment()
*/
protected function setUp() {
global $user, $language_interface, $conf;
global $user, $conf;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Create the database prefix for this test.
$this->prepareDatabasePrefix();
......
......@@ -23,7 +23,7 @@ public static function getInfo() {
* Creates a node, then tests the statistics tokens generated from it.
*/
function testStatisticsTokenReplacement() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Create user and node.
$user = $this->drupalCreateUser(array('create page content'));
......
......@@ -52,7 +52,7 @@ function hook_language_init() {
* The current path.
*/
function hook_language_switch_links_alter(array &$links, $type, $path) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language_interface->langcode])) {
foreach ($links[$language_interface->langcode] as $link) {
......
......@@ -218,7 +218,7 @@ function testRenderOverride() {
*/
function testAlter() {
// Switch the language to a right to left language and add system.base.css.
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface->direction = LANGUAGE_RTL;
$path = drupal_get_path('module', 'system');
drupal_add_css($path . '/system.base.css');
......
......@@ -41,7 +41,7 @@ function setUp() {
* Assert that the pluggable mail system is functional.
*/
public function testPluggableFramework() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Use MailTestCase for sending a message.
$message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface);
......
......@@ -29,7 +29,8 @@ function testTokenReplacement() {
$account = $this->drupalCreateUser();
$node = $this->drupalCreateNode(array('uid' => $account->uid));
$node->title = '<blink>Blinking Text</blink>';
global $user, $language_interface;
global $user;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$source = '[node:title]'; // Title of the node we passed in
$source .= '[node:author:name]'; // Node author's name
......@@ -74,7 +75,7 @@ function testTokenReplacement() {
* Test whether token-replacement works in various contexts.
*/
function testSystemTokenRecognition() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Generate prefixes and suffixes for the token context.
$tests = array(
......@@ -103,7 +104,7 @@ function testSystemTokenRecognition() {
* Tests the generation of all system site information tokens.
*/
function testSystemSiteTokenReplacement() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
......@@ -144,7 +145,7 @@ function testSystemSiteTokenReplacement() {
* Tests the generation of all system date tokens.
*/
function testSystemDateTokenReplacement() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Set time to one hour before request.
$date = REQUEST_TIME - 3600;
......
......@@ -1897,7 +1897,8 @@ function hook_custom_theme() {
* the message is not possible to translate.
*/
function hook_watchdog(array $log_entry) {
global $base_url, $language_interface;
global $base_url;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$severity_list = array(
WATCHDOG_EMERGENCY => t('Emergency'),
......
......@@ -70,7 +70,7 @@ abstract class UpgradePathTestCase extends WebTestBase {
* @see Drupal\simpletest\WebTestBase::prepareEnvironment()
*/
protected function setUp() {
global $user, $language_interface, $conf;
global $user, $conf;
// Load the Update API.
require_once DRUPAL_ROOT . '/core/includes/update.inc';
......
......@@ -1776,7 +1776,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
* Creates some terms and a node, then tests the tokens generated from them.
*/
function testTaxonomyTokenReplacement() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
// Create two taxonomy terms.
$term1 = $this->createTerm($this->vocabulary);
......
......@@ -25,7 +25,7 @@ public static function getInfo() {
* Creates a user, then tests the tokens generated from it.
*/
function testUserTokenReplacement() {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
......
......@@ -700,7 +700,8 @@ function user_user_view($account) {
* @see user_validate_mail()
*/
function user_account_form(&$form, &$form_state) {
global $user, $language_interface;
global $user;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$account = $form['#user'];
$register = ($form['#user']->uid > 0 ? FALSE : TRUE);
......
......@@ -74,7 +74,7 @@ function user_pass_validate($form, &$form_state) {
}
function user_pass_submit($form, &$form_state) {
global $language_interface;
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$account = $form_state['values']['account'];
// Mail one time login URL and instructions using current language.
......
......@@ -383,10 +383,6 @@ function update_check_requirements($skip_warnings = FALSE) {
// Determine if the current user has access to run update.php.
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
// The interface language global has been renamed in D8, we must ensure that it
// contains a valid value while language settings are upgraded.
// @todo Remove this globals reference entirely: http://drupal.org/node/1510686
$GLOBALS[LANGUAGE_TYPE_INTERFACE] = language_default();
// Ensure the default language is properly registered within the Dependency
// Injection container during the upgrade process.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment