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
a764bd3f
Commit
a764bd3f
authored
Mar 31, 2012
by
Larry Garfield
Browse files
Revert "Convert more path utility functions to just wrap the request object."
We're not ready for this yet. This reverts commit
a2f83000
.
parent
674dae32
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/includes/bootstrap.inc
View file @
a764bd3f
...
...
@@ -551,6 +551,13 @@ function drupal_environment_initialize() {
$_SERVER
[
'HTTP_HOST'
]
=
''
;
}
// When clean URLs are enabled, emulate ?q=foo/bar using REQUEST_URI. It is
// not possible to append the query string using mod_rewrite without the B
// flag (this was added in Apache 2.2.8), because mod_rewrite unescapes the
// path before passing it on to PHP. This is a problem when the path contains
// e.g. "&" or "%" that have special meanings in URLs and must be encoded.
$_GET
[
'q'
]
=
request_path
();
// Enforce E_STRICT, but allow users to set levels not part of E_STRICT.
error_reporting
(
E_STRICT
|
E_ALL
|
error_reporting
());
...
...
@@ -1512,7 +1519,7 @@ function request_uri() {
* @param Request $new_request
* The new request object to store. If you are not index.php, you probably
* should not be using this parameter.
* @return
Symfony\Component\HttpFoundation\
Request
* @return Request
* The current request object.
*/
function
request
(
Request
$new_request
=
NULL
)
{
...
...
@@ -2610,9 +2617,6 @@ function language_default() {
/**
* Returns the requested URL path of the page being viewed.
*
* @todo Eliminate this function in favor of direct access to the request
* object.
*
* Examples:
* - http://example.com/node/306 returns "node/306".
* - http://example.com/drupalfolder/node/306 returns "node/306" while
...
...
@@ -2628,7 +2632,45 @@ function language_default() {
* @see current_path()
*/
function
request_path
()
{
return
request
()
->
getPathInfo
();
static
$path
;
if
(
isset
(
$path
))
{
return
$path
;
}
if
(
isset
(
$_GET
[
'q'
]))
{
// This is a request with a ?q=foo/bar query string. $_GET['q'] is
// overwritten in drupal_path_initialize(), but request_path() is called
// very early in the bootstrap process, so the original value is saved in
// $path and returned in later calls.
$path
=
$_GET
[
'q'
];
}
elseif
(
isset
(
$_SERVER
[
'REQUEST_URI'
]))
{
// This request is either a clean URL, or 'index.php', or nonsense.
// Extract the path from REQUEST_URI.
$request_path
=
strtok
(
$_SERVER
[
'REQUEST_URI'
],
'?'
);
$base_path_len
=
strlen
(
rtrim
(
dirname
(
$_SERVER
[
'SCRIPT_NAME'
]),
'\/'
));
// Unescape and strip $base_path prefix, leaving q without a leading slash.
$path
=
substr
(
urldecode
(
$request_path
),
$base_path_len
+
1
);
// If the path equals the script filename, either because 'index.php' was
// explicitly provided in the URL, or because the server added it to
// $_SERVER['REQUEST_URI'] even when it wasn't provided in the URL (some
// versions of Microsoft IIS do this), the front page should be served.
if
(
$path
==
basename
(
$_SERVER
[
'PHP_SELF'
]))
{
$path
=
''
;
}
}
else
{
// This is the front page.
$path
=
''
;
}
// Under certain conditions Apache's RewriteRule directive prepends the value
// assigned to $_GET['q'] with a slash. Moreover we can always have a trailing
// slash in place, hence we need to normalize $_GET['q'].
$path
=
trim
(
$path
,
'/'
);
return
$path
;
}
/**
...
...
core/includes/common.inc
View file @
a764bd3f
...
...
@@ -2735,10 +2735,6 @@ function drupal_get_path($type, $name) {
/**
* Returns the base URL path (i.e., directory) of the Drupal installation.
*
* @todo Eliminate this function in favor of direct access to the request. Or,
* better yet, eliminate the need for this function outside of the
* URL Generator.
*
* base_path() adds a "/" to the beginning and end of the returned path if the
* path is not empty. At the very least, this will return "/".
*
...
...
@@ -2747,7 +2743,7 @@ function drupal_get_path($type, $name) {
* - http://example.com/drupal/folder returns "/drupal/folder/".
*/
function
base_path
()
{
return
request
()
->
getB
ase
P
ath
()
.
'/
'
;
return
$GLOBALS
[
'b
ase
_p
ath'
]
;
}
/**
...
...
core/includes/path.inc
View file @
a764bd3f
...
...
@@ -334,10 +334,7 @@ function drupal_match_path($path, $patterns) {
/**
* Return the current URL path of the page being viewed.
*
* @todo Eliminate this function in favor of direct access to the request
* object.
*
* Examples:
* Examples:
* - http://example.com/node/306 returns "node/306".
* - http://example.com/drupalfolder/node/306 returns "node/306" while
* base_path() returns "/drupalfolder/".
...
...
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