Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
9f25d6a5
Commit
9f25d6a5
authored
Nov 19, 2011
by
Nathaniel Catchpole
Browse files
Issue
#1329914
by xjm, msonnabaum: Ensure ['q'] is set before calling drupal_normal_path().
parent
ccbadedd
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/includes/path.inc
View file @
9f25d6a5
...
...
@@ -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'
]);
}
/**
...
...
core/modules/simpletest/tests/path.test
View file @
9f25d6a5
...
...
@@ -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.
*
...
...
core/modules/simpletest/tests/url_alter_test.module
View file @
9f25d6a5
...
...
@@ -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
]))
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment