diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 1c8068b..13b463e 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -1028,33 +1028,16 @@ protected function initializeSettings(Request $request) { * @todo D8: Eliminate this entirely in favor of Request object. */ protected function initializeRequestGlobals(Request $request) { - global $base_url; - // Set and derived from $base_url by this function. - global $base_path, $base_root; + global $base_path, $base_root, $base_url; global $base_secure_url, $base_insecure_url; - - // 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 .= '/'; + if (substr($request->getBasePath(), -5) == '/core') { + $base_path = substr($request->getBasePath(), 0, strlen($request->getBasePath()) - 4); } else { - $base_path = '/'; + $base_path = $request->getBasePath() . '/'; } + $base_root = $request->getSchemeAndHttpHost(); + $base_url = rtrim($base_root . $base_path, '\/'); $base_secure_url = str_replace('http://', 'https://', $base_url); $base_insecure_url = str_replace('https://', 'http://', $base_url); } @@ -1509,3 +1492,4 @@ protected function addServiceFiles(array $service_yamls) { } } +