diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 2ddc3eebfdf6429521f338f90c18e290d3f0629b..16b3baca2a18f669c48193eefb0c3406741629e9 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -992,47 +992,32 @@ protected function initializeSettings(Request $request) { * @todo D8: Eliminate this entirely in favor of Request object. */ protected function initializeRequestGlobals(Request $request) { - // Provided by settings.php. global $base_url; // Set and derived from $base_url by this function. global $base_path, $base_root; global $base_secure_url, $base_insecure_url; - // @todo Refactor with the Symfony Request object. - if (isset($base_url)) { - // Parse fixed base URL from settings.php. - $parts = parse_url($base_url); - if (!isset($parts['path'])) { - $parts['path'] = ''; - } - $base_path = $parts['path'] . '/'; - // Build $base_root (everything until first slash after "scheme://"). - $base_root = substr($base_url, 0, strlen($base_url) - strlen($parts['path'])); - } - else { - // Create base URL. - $base_root = $request->getSchemeAndHttpHost(); - - $base_url = $base_root; - - // For a request URI of '/index.php/foo', $_SERVER['SCRIPT_NAME'] is - // '/index.php', whereas $_SERVER['PHP_SELF'] is '/index.php/foo'. - if ($dir = rtrim(dirname($request->server->get('SCRIPT_NAME')), '\/')) { - // Remove "core" directory if present, allowing install.php, - // authorize.php, and others to auto-detect a base path. - $core_position = strrpos($dir, '/core'); - if ($core_position !== FALSE && strlen($dir) - 5 == $core_position) { - $base_path = substr($dir, 0, $core_position); - } - else { - $base_path = $dir; - } - $base_url .= $base_path; - $base_path .= '/'; + // Create base URL. + $base_root = $request->getSchemeAndHttpHost(); + $base_url = $base_root; + + // For a request URI of '/index.php/foo', $_SERVER['SCRIPT_NAME'] is + // '/index.php', whereas $_SERVER['PHP_SELF'] is '/index.php/foo'. + if ($dir = rtrim(dirname($request->server->get('SCRIPT_NAME')), '\/')) { + // Remove "core" directory if present, allowing install.php, + // authorize.php, and others to auto-detect a base path. + $core_position = strrpos($dir, '/core'); + if ($core_position !== FALSE && strlen($dir) - 5 == $core_position) { + $base_path = substr($dir, 0, $core_position); } else { - $base_path = '/'; + $base_path = $dir; } + $base_url .= $base_path; + $base_path .= '/'; + } + else { + $base_path = '/'; } $base_secure_url = str_replace('http://', 'https://', $base_url); $base_insecure_url = str_replace('https://', 'http://', $base_url); diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php index 3b3706385101536269118725b1d3d062d428a973..ee786db891194c65eae1570f603f412667a22b98 100644 --- a/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -112,7 +112,7 @@ public static function getAll() { */ public static function initialize($app_root, $site_path, &$class_loader) { // Export these settings.php variables to the global namespace. - global $base_url, $config_directories, $config; + global $config_directories, $config; $settings = array(); $config = array(); $databases = array(); diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index 1ea5d727efa7032724363844b5c9af04b18549a2..7d3a3ae44292063d909e77320ed5193d7d2d57ed 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -527,28 +527,6 @@ */ # $settings['maintenance_theme'] = 'bartik'; -/** - * Base URL (optional). - * - * If Drupal is generating incorrect URLs on your site, which could - * be in HTML headers (links to CSS and JS files) or visible links on pages - * (such as in menus), uncomment the Base URL statement below (remove the - * leading hash sign) and fill in the absolute URL to your Drupal installation. - * - * You might also want to force users to use a given domain. - * See the .htaccess file for more information. - * - * Examples: - * $base_url = 'http://www.example.com'; - * $base_url = 'http://www.example.com:8888'; - * $base_url = 'http://www.example.com/drupal'; - * $base_url = 'https://www.example.com:8888/drupal'; - * - * It is not allowed to have a trailing slash; Drupal will add it - * for you. - */ -# $base_url = 'http://www.example.com'; // NO trailing slash! - /** * PHP settings: *