Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
221
Merge Requests
221
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
a2f83000
Commit
a2f83000
authored
Mar 31, 2012
by
Crell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert more path utility functions to just wrap the request object.
parent
151c391b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
49 deletions
+14
-49
core/includes/bootstrap.inc
core/includes/bootstrap.inc
+5
-47
core/includes/common.inc
core/includes/common.inc
+5
-1
core/includes/path.inc
core/includes/path.inc
+4
-1
No files found.
core/includes/bootstrap.inc
View file @
a2f83000
...
...
@@ -551,13 +551,6 @@ 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
());
...
...
@@ -1519,7 +1512,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 Request
* @return
Symfony\Component\HttpFoundation\
Request
* The current request object.
*/
function
request
(
Request
$new_request
=
NULL
)
{
...
...
@@ -2617,6 +2610,9 @@ 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
...
...
@@ -2632,45 +2628,7 @@ function language_default() {
* @see current_path()
*/
function
request_path
()
{
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
;
return
request
()
->
getPathInfo
();
}
/**
...
...
core/includes/common.inc
View file @
a2f83000
...
...
@@ -2735,6 +2735,10 @@ 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 "/".
*
...
...
@@ -2743,7 +2747,7 @@ function drupal_get_path($type, $name) {
* - http://example.com/drupal/folder returns "/drupal/folder/".
*/
function
base_path
()
{
return
$GLOBALS
[
'base_path'
]
;
return
request
()
->
getBasePath
()
.
'/'
;
}
/**
...
...
core/includes/path.inc
View file @
a2f83000
...
...
@@ -334,7 +334,10 @@ function drupal_match_path($path, $patterns) {
/**
* Return the current URL path of the page being viewed.
*
* Examples:
* @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
* base_path() returns "/drupalfolder/".
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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