diff --git a/core/includes/path.inc b/core/includes/path.inc index 630b34c..d442adb 100644 --- a/core/includes/path.inc +++ b/core/includes/path.inc @@ -13,12 +13,10 @@ * 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')); - } + if (empty($_GET['q'])) { + $_GET['q'] = variable_get('site_frontpage', 'node'); + } + $_GET['q'] = drupal_get_normal_path($_GET['q']); } /** diff --git a/core/modules/simpletest/tests/path.test b/core/modules/simpletest/tests/path.test index 82598b5..9406a65 100644 --- a/core/modules/simpletest/tests/path.test +++ b/core/modules/simpletest/tests/path.test @@ -201,6 +201,14 @@ class UrlAlterFunctionalTest extends DrupalWebTestCase { } /** + * 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. * * @param $original diff --git a/core/modules/simpletest/tests/url_alter_test.module b/core/modules/simpletest/tests/url_alter_test.module index e229ab9..9287ff5 100644 --- a/core/modules/simpletest/tests/url_alter_test.module +++ b/core/modules/simpletest/tests/url_alter_test.module @@ -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])) {