Skip to content
Snippets Groups Projects
Commit 9f25d6a5 authored by catch's avatar catch
Browse files

Issue #1329914 by xjm, msonnabaum: Ensure ['q'] is set before calling drupal_normal_path().

parent ccbadedd
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -13,12 +13,11 @@
* Initialize the $_GET['q'] variable to the proper normal path.
*/
function drupal_path_initialize() {
if (!empty($_GET['q'])) {
$_GET['q'] = drupal_get_normal_path($_GET['q']);
}
else {
$_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
// Ensure $_GET['q'] is set before calling drupal_normal_path().
if (empty($_GET['q'])) {
$_GET['q'] = variable_get('site_frontpage', 'node');
}
$_GET['q'] = drupal_get_normal_path($_GET['q']);
}
/**
......
......@@ -200,6 +200,14 @@ class UrlAlterFunctionalTest extends DrupalWebTestCase {
$this->assertRaw('current_path=url-alter-test/foo', t('current_path() returns the internal path.'));
}
/**
* Tests that $_GET['q'] is initialized when the request path is empty.
*/
function testGetQInitialized() {
$this->drupalGet('');
$this->assertText("\$_GET['q'] is non-empty with an empty request path.", "\$_GET['q'] is initialized with an empty request path.");
}
/**
* Assert that an outbound path is altered to an expected value.
*
......
......@@ -30,6 +30,10 @@ function url_alter_test_foo() {
* Implements hook_url_inbound_alter().
*/
function url_alter_test_url_inbound_alter(&$path, $original_path, $path_language) {
if (!request_path() && !empty($_GET['q'])) {
drupal_set_message("\$_GET['q'] is non-empty with an empty request path.");
}
// Rewrite user/username to user/uid.
if (preg_match('!^user/([^/]+)(/.*)?!', $path, $matches)) {
if ($account = user_load_by_name($matches[1])) {
......
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