From cbcf2722758e2e30715e40f87c5f9bda645202bf Mon Sep 17 00:00:00 2001 From: webchick <drupal@webchick.net> Date: Tue, 17 Mar 2015 13:59:45 -0700 Subject: [PATCH] Issue #2426495 by dawehner, alexpott: Remove the global $script_path --- core/lib/Drupal/Core/DrupalKernel.php | 30 +------------------ .../LanguageUILanguageNegotiationTest.php | 2 +- .../locale/src/Tests/LocalePathTest.php | 3 +- .../src/Tests/Path/UrlAlterFunctionalTest.php | 4 +-- 4 files changed, 6 insertions(+), 33 deletions(-) diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 4e2c30a93263..eb841b29dda7 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -815,7 +815,7 @@ 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, $script_path; + global $base_path, $base_root; global $base_secure_url, $base_insecure_url; // @todo Refactor with the Symfony Request object. @@ -856,34 +856,6 @@ protected function initializeRequestGlobals(Request $request) { } $base_secure_url = str_replace('http://', 'https://', $base_url); $base_insecure_url = str_replace('https://', 'http://', $base_url); - - // Determine the path of the script relative to the base path, and add a - // trailing slash. This is needed for creating URLs to Drupal pages. - if (!isset($script_path)) { - $script_path = ''; - // We don't expect scripts outside of the base path, but sanity check - // anyway. - if (strpos($request->server->get('SCRIPT_NAME'), $base_path) === 0) { - $script_path = substr($request->server->get('SCRIPT_NAME'), strlen($base_path)) . '/'; - // If the request URI does not contain the script name, then clean URLs - // are in effect and the script path can be similarly dropped from URL - // generation. For servers that don't provide $_SERVER['REQUEST_URI'], - // we do not know the actual URI requested by the client, and - // $request->getPathInfo() returns a URI with the script name, - // resulting in non-clean URLs unless - // there's other code that intervenes. - if (strpos($request->getPathInfo() . '/', $base_path . $script_path) !== 0) { - $script_path = ''; - } - // @todo Temporary BC for install.php, authorize.php, and other scripts. - // - http://drupal.org/node/1547184 - // - http://drupal.org/node/1546082 - if ($script_path !== 'index.php/') { - $script_path = ''; - } - } - } - } /** diff --git a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php index e584fb75d1f9..f801b6ae8889 100644 --- a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php @@ -409,7 +409,7 @@ function testUrlLanguageFallback() { // Check that the language switcher active link matches the given browser // language. - $args = array(':id' => 'block-test-language-block', ':url' => base_path() . $GLOBALS['script_path'] . $langcode_browser_fallback); + $args = array(':id' => 'block-test-language-block', ':url' => \Drupal::url('<front>') . $langcode_browser_fallback); $fields = $this->xpath('//div[@id=:id]//a[@class="language-link active" and starts-with(@href, :url)]', $args); $this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language'); diff --git a/core/modules/locale/src/Tests/LocalePathTest.php b/core/modules/locale/src/Tests/LocalePathTest.php index cb0b86b55537..851f3d6065ce 100644 --- a/core/modules/locale/src/Tests/LocalePathTest.php +++ b/core/modules/locale/src/Tests/LocalePathTest.php @@ -8,6 +8,7 @@ namespace Drupal\locale\Tests; use Drupal\Core\Language\LanguageInterface; +use Drupal\Core\Url; use Drupal\simpletest\WebTestBase; /** @@ -136,7 +137,7 @@ public function testPathLanguageConfiguration() { // Test that both node titles link to our path alias. $this->drupalGet('admin/content'); - $custom_path_url = base_path() . $GLOBALS['script_path'] . $custom_path; + $custom_path_url = Url::fromUserInput('/' . $custom_path)->toString(); $elements = $this->xpath('//a[@href=:href and normalize-space(text())=:title]', array(':href' => $custom_path_url, ':title' => $first_node->label())); $this->assertTrue(!empty($elements), 'First node links to the path alias.'); $elements = $this->xpath('//a[@href=:href and normalize-space(text())=:title]', array(':href' => $custom_path_url, ':title' => $second_node->label())); diff --git a/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php b/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php index c62decbe1b39..1988708533e2 100644 --- a/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php +++ b/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Path; +use Drupal\Core\Url; use Drupal\simpletest\WebTestBase; /** @@ -87,8 +88,7 @@ function testUrlAlter() { protected function assertUrlOutboundAlter($original, $final) { // Test outbound altering. $result = $this->container->get('url_generator')->generateFromPath($original); - $base_path = base_path() . $GLOBALS['script_path']; - $result = substr($result, strlen($base_path)); + $final = Url::fromUri('internal:/' . $final)->toString(); $this->assertIdentical($result, $final, format_string('Altered outbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result))); } -- GitLab