Skip to content
Snippets Groups Projects
Commit cbcf2722 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2426495 by dawehner, alexpott: Remove the global $script_path

parent 1cff0975
No related branches found
No related tags found
No related merge requests found
......@@ -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 = '';
}
}
}
}
/**
......
......@@ -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');
......
......@@ -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()));
......
......@@ -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)));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment