diff --git a/core/authorize.php b/core/authorize.php
index c6ba51d..d703b33 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -103,17 +103,6 @@ if (authorize_access_allowed()) {
// Load the code that drives the authorize process.
require_once DRUPAL_ROOT . '/core/includes/authorize.inc';
- // For the sake of Batch API and a few other low-level functions, we need to
- // initialize the URL path into $_GET['q']. However, we do not want to raise
- // our bootstrap level, nor do we want to call drupal_initialize_path(),
- // since that is assuming that modules are loaded and invoking hooks.
- // However, all we really care is if we're in the middle of a batch, in which
- // case $_GET['q'] will already be set, we just initialize it to an empty
- // string if it's not already defined.
- if (!isset($_GET['q'])) {
- $_GET['q'] = '';
- }
-
if (isset($_SESSION['authorize_operation']['page_title'])) {
drupal_set_title($_SESSION['authorize_operation']['page_title']);
}
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 39bc55c..0b4a784 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -721,12 +721,8 @@ 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();
+ // @todo Refactor with the Symfony Request object.
+ _current_path(request_path());
// Enforce E_STRICT, but allow users to set levels not part of E_STRICT.
error_reporting(E_STRICT | E_ALL | error_reporting());
@@ -2356,7 +2352,7 @@ function _drupal_bootstrap_page_cache() {
if (is_object($cache)) {
header('X-Drupal-Cache: HIT');
// Restore the metadata cached with the page.
- $_GET['q'] = $cache->data['path'];
+ _current_path($cache->data['path']);
drupal_set_title($cache->data['title'], PASS_THROUGH);
date_default_timezone_set(drupal_get_user_timezone());
// If the skipping of the bootstrap hooks is not enforced, call
@@ -2556,9 +2552,9 @@ function drupal_maintenance_theme() {
*/
function drupal_fast_404() {
$exclude_paths = variable_get('404_fast_paths_exclude', FALSE);
- if ($exclude_paths && !preg_match($exclude_paths, $_GET['q'])) {
+ if ($exclude_paths && !preg_match($exclude_paths, request_path())) {
$fast_paths = variable_get('404_fast_paths', FALSE);
- if ($fast_paths && preg_match($fast_paths, $_GET['q'])) {
+ if ($fast_paths && preg_match($fast_paths, request_path())) {
drupal_add_http_header('Status', '404 Not Found');
$fast_404_html = variable_get('404_fast_html', '
404 Not FoundNot Found
The requested URL "@path" was not found on this server.
');
// Replace @path in the variable with the page path.
@@ -2786,19 +2782,13 @@ function request_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'])) {
+ if (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.
+ // Unescape and strip $base_path prefix, leaving $path 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
@@ -2813,15 +2803,26 @@ function request_path() {
$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'].
+ // Extra slashes can appear in URLs or under some conditions, added by Apache,
+ // so normalize.
$path = trim($path, '/');
return $path;
}
/**
+ * @todo This is a temporary function pending refactoring Drupal to use
+ * Symfony's Request object exclusively.
+ */
+function _current_path($path = NULL) {
+ static $current_path = '';
+ if (isset($path)) {
+ $current_path = $path;
+ }
+ return $current_path;
+}
+
+/**
* Returns a component of the current Drupal path.
*
* When viewing a page at the path "admin/structure/types", for example, arg(0)
@@ -2857,7 +2858,7 @@ function arg($index = NULL, $path = NULL) {
$arguments = &$drupal_static_fast['arguments'];
if (!isset($path)) {
- $path = $_GET['q'];
+ $path = current_path();
}
if (!isset($arguments[$path])) {
$arguments[$path] = explode('/', $path);
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 3837afd..bef2793 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -388,14 +388,14 @@ function drupal_get_feeds($delimiter = "\n") {
* (optional) An array to be processed. Defaults to $_GET.
* @param $exclude
* (optional) A list of $query array keys to remove. Use "parent[child]" to
- * exclude nested items. Defaults to array('q').
+ * exclude nested items.
* @param $parent
* Internal use only. Used to build the $query array key for nested items.
*
* @return
* An array containing query parameters, which can be used for url().
*/
-function drupal_get_query_parameters(array $query = NULL, array $exclude = array('q'), $parent = '') {
+function drupal_get_query_parameters(array $query = NULL, array $exclude = array(), $parent = '') {
// Set defaults, if none given.
if (!isset($query)) {
$query = $_GET;
@@ -508,7 +508,7 @@ function drupal_get_destination() {
$destination = array('destination' => $_GET['destination']);
}
else {
- $path = $_GET['q'];
+ $path = current_path();
$query = drupal_http_build_query(drupal_get_query_parameters());
if ($query != '') {
$path .= '?' . $query;
@@ -589,13 +589,6 @@ function drupal_parse_url($url) {
$options['fragment'] = $parts['fragment'];
}
}
- // The 'q' parameter contains the path of the current page if clean URLs are
- // disabled. It overrides the 'path' of the URL when present, even if clean
- // URLs are enabled, due to how Apache rewriting rules work.
- if (isset($options['query']['q'])) {
- $options['path'] = $options['query']['q'];
- unset($options['query']['q']);
- }
return $options;
}
@@ -2079,14 +2072,6 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
* dependent URL requires so.
* - 'prefix': Only used internally, to modify the path when a language
* dependent URL requires so.
- * - 'script': The script filename in Drupal's root directory to use when
- * clean URLs are disabled, such as 'index.php'. Defaults to an empty
- * string, as most modern web servers automatically find 'index.php'. If
- * clean URLs are disabled, the value of $path is appended as query
- * parameter 'q' to $options['script'] in the returned URL. When deploying
- * Drupal on a web server that cannot be configured to automatically find
- * index.php, then hook_url_outbound_alter() can be implemented to force
- * this value to 'index.php'.
* - 'entity_type': The entity type of the object that called url(). Only
* set if url() is invoked by entity_uri().
* - 'entity': The entity object (such as a node) for which the URL is being
@@ -2184,11 +2169,11 @@ function url($path = NULL, array $options = array()) {
$base = $options['absolute'] ? $options['base_url'] . '/' : base_path();
$prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
- // If Clean URLs are not enabled, we need to prefix the script name onto
- // the link.
+ // If we were called with index.php (instead of using a clean URL), then
+ // output links with index.php as well.
// @todo: Make this dynamic based on the request object without using a global
// request object.
- if (empty($GLOBALS['conf']['clean_url'])) {
+ if (strpos($_SERVER['REQUEST_URI'], base_path() . 'index.php') === 0) {
$base .= 'index.php/';
}
@@ -2335,7 +2320,7 @@ function l($text, $path, array $options = array()) {
);
// Append active class.
- if (($path == $_GET['q'] || ($path == '' && drupal_is_front_page())) &&
+ if (($path == current_path() || ($path == '' && drupal_is_front_page())) &&
(empty($options['language']) || $options['language']->langcode == $language_url->langcode)) {
$options['attributes']['class'][] = 'active';
}
@@ -2461,7 +2446,7 @@ function drupal_deliver_page($page_callback_result, $default_delivery_callback =
// If a delivery callback is specified, but doesn't exist as a function,
// something is wrong, but don't print anything, since it's not known
// what format the response needs to be in.
- watchdog('delivery callback not found', 'callback %callback not found: %q.', array('%callback' => $delivery_callback, '%q' => $_GET['q']), WATCHDOG_ERROR);
+ watchdog('delivery callback not found', 'callback %callback not found: %path.', array('%callback' => $delivery_callback, '%path' => current_path()), WATCHDOG_ERROR);
}
}
@@ -2498,18 +2483,18 @@ function drupal_deliver_html_page($page_callback_result) {
// Print a 404 page.
drupal_add_http_header('Status', '404 Not Found');
- watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
+ watchdog('page not found', check_plain(current_path()), NULL, WATCHDOG_WARNING);
// Check for and return a fast 404 page if configured.
drupal_fast_404();
// Keep old path for reference, and to allow forms to redirect to it.
if (!isset($_GET['destination'])) {
- $_GET['destination'] = $_GET['q'];
+ $_GET['destination'] = current_path();
}
$path = drupal_get_normal_path(variable_get('site_404', ''));
- if ($path && $path != $_GET['q']) {
+ if ($path && $path != current_path()) {
// Custom 404 handler. Set the active item in case there are tabs to
// display, or other dependencies on the path.
menu_set_active_item($path);
@@ -2530,15 +2515,15 @@ function drupal_deliver_html_page($page_callback_result) {
case MENU_ACCESS_DENIED:
// Print a 403 page.
drupal_add_http_header('Status', '403 Forbidden');
- watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
+ watchdog('access denied', check_plain(current_path()), NULL, WATCHDOG_WARNING);
// Keep old path for reference, and to allow forms to redirect to it.
if (!isset($_GET['destination'])) {
- $_GET['destination'] = $_GET['q'];
+ $_GET['destination'] = current_path();
}
$path = drupal_get_normal_path(variable_get('site_403', ''));
- if ($path && $path != $_GET['q']) {
+ if ($path && $path != current_path()) {
// Custom 403 handler. Set the active item in case there are tabs to
// display or other dependencies on the path.
menu_set_active_item($path);
@@ -5131,7 +5116,7 @@ function _drupal_bootstrap_full() {
ini_set('error_log', 'public://error.log');
}
- // Initialize $_GET['q'] prior to invoking hook_init().
+ // Initialize current_path() prior to invoking hook_init().
drupal_path_initialize();
// Let all modules take action before the menu system handles the request.
@@ -5170,7 +5155,7 @@ function drupal_page_set_cache() {
$cache = (object) array(
'cid' => $base_root . request_uri(),
'data' => array(
- 'path' => $_GET['q'],
+ 'path' => current_path(),
'body' => ob_get_clean(),
'title' => drupal_get_title(),
'headers' => array(),
diff --git a/core/includes/file.inc b/core/includes/file.inc
index 9e85ba9..03fb9b4 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -1967,7 +1967,7 @@ function file_transfer($uri, $headers) {
* @see system_menu()
*/
function file_download() {
- // Merge remainder of arguments from GET['q'], into relative file path.
+ // Merge remaining path arguments into relative file path.
$args = func_get_args();
$scheme = array_shift($args);
$target = implode('/', $args);
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 0124abc..29a9f71 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -1248,7 +1248,7 @@ function drupal_redirect_form($form_state) {
$function($form_state['redirect']);
}
}
- drupal_goto($_GET['q']);
+ drupal_goto(current_path());
}
}
@@ -4454,7 +4454,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
'progressive' => TRUE,
'url' => $url,
'url_options' => array(),
- 'source_url' => $_GET['q'],
+ 'source_url' => current_path(),
'redirect' => $redirect,
'theme' => $GLOBALS['theme_key'],
'redirect_callback' => $redirect_callback,
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 493246c..3df3b5d 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1839,12 +1839,6 @@ function _install_configure_form($form, &$form_state, &$install_state) {
'#attributes' => array('class' => array('timezone-detect')),
);
- $form['server_settings']['clean_url'] = array(
- '#type' => 'hidden',
- '#default_value' => 0,
- '#attributes' => array('id' => 'edit-clean-url', 'class' => array('install')),
- );
-
$form['update_notifications'] = array(
'#type' => 'fieldset',
'#title' => st('Update notifications'),
@@ -1910,10 +1904,6 @@ function install_configure_form_submit($form, &$form_state) {
$user = user_load(1);
user_login_finalize();
- if (isset($form_state['values']['clean_url'])) {
- variable_set('clean_url', $form_state['values']['clean_url']);
- }
-
// Record when this install ran.
variable_set('install_time', $_SERVER['REQUEST_TIME']);
}
diff --git a/core/includes/locale.inc b/core/includes/locale.inc
index 1f9567b..4783baa 100644
--- a/core/includes/locale.inc
+++ b/core/includes/locale.inc
@@ -270,9 +270,8 @@ function locale_language_from_url($languages) {
switch (variable_get('locale_language_negotiation_url_part', LANGUAGE_NEGOTIATION_URL_PREFIX)) {
case LANGUAGE_NEGOTIATION_URL_PREFIX:
- // $_GET['q'] might not be available at this time, because
- // path initialization runs after the language bootstrap phase.
- list($language, $_GET['q']) = language_url_split_prefix(isset($_GET['q']) ? $_GET['q'] : NULL, $languages);
+ list($language, $path) = language_url_split_prefix(request_path(), $languages);
+ _current_path($path);
if ($language !== FALSE) {
$language_url = $language->langcode;
}
@@ -384,7 +383,6 @@ function locale_language_switcher_session($type, $path) {
$links = array();
$query = $_GET;
- unset($query['q']);
foreach ($languages as $language) {
$langcode = $language->langcode;
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 6974bec..c767979 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -434,7 +434,7 @@ function menu_set_item($path, $router_item) {
function menu_get_item($path = NULL, $router_item = NULL) {
$router_items = &drupal_static(__FUNCTION__);
if (!isset($path)) {
- $path = $_GET['q'];
+ $path = current_path();
}
if (isset($router_item)) {
$router_items[$path] = $router_item;
@@ -491,7 +491,7 @@ function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
// Allow other modules to change the site status but not the path because that
// would not change the global variable. hook_url_inbound_alter() can be used
// to change the path. Code later will not use the $read_only_path variable.
- $read_only_path = !empty($path) ? $path : $_GET['q'];
+ $read_only_path = !empty($path) ? $path : current_path();
drupal_alter('menu_site_status', $page_callback_result, $read_only_path);
// Only continue if the site status is not set.
@@ -1036,11 +1036,11 @@ function menu_tree_output($tree) {
$class[] = 'active-trail';
$data['link']['localized_options']['attributes']['class'][] = 'active-trail';
}
- // Normally, l() compares the href of every link with $_GET['q'] and sets
- // the active class accordingly. But local tasks do not appear in menu
+ // Normally, l() compares the href of every link with the current path and
+ // sets the active class accordingly. But local tasks do not appear in menu
// trees, so if the current path is a local task, and this link is its
// tab root, then we have to set the class manually.
- if ($data['link']['href'] == $router_item['tab_root_href'] && $data['link']['href'] != $_GET['q']) {
+ if ($data['link']['href'] == $router_item['tab_root_href'] && $data['link']['href'] != current_path()) {
$data['link']['localized_options']['attributes']['class'][] = 'active';
}
@@ -1833,11 +1833,11 @@ function menu_navigation_links($menu_name, $level = 0) {
$class = ' active-trail';
$l['attributes']['class'][] = 'active-trail';
}
- // Normally, l() compares the href of every link with $_GET['q'] and sets
- // the active class accordingly. But local tasks do not appear in menu
- // trees, so if the current path is a local task, and this link is its
- // tab root, then we have to set the class manually.
- if ($item['link']['href'] == $router_item['tab_root_href'] && $item['link']['href'] != $_GET['q']) {
+ // Normally, l() compares the href of every link with the current path and
+ // sets the active class accordingly. But local tasks do not appear in
+ // menu trees, so if the current path is a local task, and this link is
+ // its tab root, then we have to set the class manually.
+ if ($item['link']['href'] == $router_item['tab_root_href'] && $item['link']['href'] != current_path()) {
$l['attributes']['class'][] = 'active';
}
// Keyed with the unique mlid to generate classes in theme_links().
@@ -1951,8 +1951,8 @@ function menu_local_tasks($level = 0) {
// local tasks link to their parent, but the path of default local
// tasks can still be accessed directly, in which case this link
// would not be marked as active, since l() only compares the href
- // with $_GET['q'].
- if ($link['href'] != $_GET['q']) {
+ // with current_path().
+ if ($link['href'] != current_path()) {
$link['localized_options']['attributes']['class'][] = 'active';
}
$tabs_current[] = array(
@@ -2027,8 +2027,8 @@ function menu_local_tasks($level = 0) {
// Mark the link as active, if the current path is a (second-level)
// local task of a default local task. Since this default local task
// links to its parent, l() will not mark it as active, as it only
- // compares the link's href to $_GET['q'].
- if ($link['href'] != $_GET['q']) {
+ // compares the link's href to current_path().
+ if ($link['href'] != current_path()) {
$link['localized_options']['attributes']['class'][] = 'active';
}
$tabs_current[] = array(
@@ -2291,7 +2291,8 @@ function menu_get_active_menu_names() {
* A Drupal path - not a path alias.
*/
function menu_set_active_item($path) {
- $_GET['q'] = $path;
+ // @todo Refactor to use the Symfony Request object.
+ _current_path($path);
}
/**
@@ -2405,7 +2406,7 @@ function menu_link_get_preferred($path = NULL, $selected_menu = NULL) {
$preferred_links = &drupal_static(__FUNCTION__);
if (!isset($path)) {
- $path = $_GET['q'];
+ $path = current_path();
}
if (empty($selected_menu)) {
@@ -3786,7 +3787,7 @@ function _menu_site_is_offline($check_only = FALSE) {
// Ensure that the maintenance mode message is displayed only once
// (allowing for page redirects) and specifically suppress its display on
// the maintenance mode settings page.
- if (!$check_only && $_GET['q'] != 'admin/config/development/maintenance') {
+ if (!$check_only && current_path() != 'admin/config/development/maintenance') {
if (user_access('administer site configuration')) {
drupal_set_message(t('Operating in maintenance mode. Go online.', array('@url' => url('admin/config/development/maintenance'))), 'status', FALSE);
}
diff --git a/core/includes/pager.inc b/core/includes/pager.inc
index c579e7e..201c5ad 100644
--- a/core/includes/pager.inc
+++ b/core/includes/pager.inc
@@ -297,7 +297,7 @@ function pager_default_initialize($total, $limit, $element = 0) {
function pager_get_query_parameters() {
$query = &drupal_static(__FUNCTION__);
if (!isset($query)) {
- $query = drupal_get_query_parameters($_GET, array('q', 'page'));
+ $query = drupal_get_query_parameters($_GET, array('page'));
}
return $query;
}
@@ -638,7 +638,7 @@ function theme_pager_link($variables) {
// none of the pager links is active at any time - but it should still be
// possible to use l() here.
// @see http://drupal.org/node/1410574
- $attributes['href'] = url($_GET['q'], array('query' => $query));
+ $attributes['href'] = url(current_path(), array('query' => $query));
return '' . check_plain($text) . '';
}
diff --git a/core/includes/path.inc b/core/includes/path.inc
index b49d42b..6faa961 100644
--- a/core/includes/path.inc
+++ b/core/includes/path.inc
@@ -10,15 +10,16 @@
*/
/**
- * Initialize the $_GET['q'] variable to the proper normal path.
+ * Initialize the current path.
*/
function drupal_path_initialize() {
- // Ensure $_GET['q'] is set before calling drupal_normal_path(), to support
- // path caching with hook_url_inbound_alter().
- if (empty($_GET['q'])) {
- $_GET['q'] = variable_get('site_frontpage', 'user');
+ if (!current_path()) {
+ if (!($path = request_path())) {
+ $path = variable_get('site_frontpage', 'user');
+ }
}
- $_GET['q'] = drupal_get_normal_path($_GET['q']);
+ $path = drupal_get_normal_path($path);
+ _current_path($path);
}
/**
@@ -235,7 +236,7 @@ function drupal_cache_system_paths() {
function drupal_get_path_alias($path = NULL, $langcode = NULL) {
// If no path is specified, use the current page's path.
if ($path == NULL) {
- $path = $_GET['q'];
+ $path = current_path();
}
$result = $path;
if ($alias = drupal_lookup_path('alias', $path, $langcode)) {
@@ -290,9 +291,7 @@ function drupal_is_front_page() {
$is_front_page = &$drupal_static_fast['is_front_page'];
if (!isset($is_front_page)) {
- // As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path,
- // we can check it against the 'site_frontpage' variable.
- $is_front_page = ($_GET['q'] == variable_get('site_frontpage', 'user'));
+ $is_front_page = (current_path() == variable_get('site_frontpage', 'user'));
}
return $is_front_page;
@@ -341,9 +340,9 @@ function drupal_match_path($path, $patterns) {
* - http://example.com/path/alias (which is a path alias for node/306) returns
* "node/306" as opposed to the path alias.
*
- * This function is not available in hook_boot() so use $_GET['q'] instead.
+ * This function is not available in hook_boot() so use request_path() instead.
* However, be careful when doing that because in the case of Example #3
- * $_GET['q'] will contain "path/alias". If "node/306" is needed, calling
+ * request_path() will contain "path/alias". If "node/306" is needed, calling
* drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) makes this function available.
*
* @return
@@ -352,7 +351,7 @@ function drupal_match_path($path, $patterns) {
* @see request_path()
*/
function current_path() {
- return $_GET['q'];
+ return _current_path();
}
/**
diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc
index 3c70b96..a900a61 100644
--- a/core/includes/tablesort.inc
+++ b/core/includes/tablesort.inc
@@ -150,7 +150,7 @@ function tablesort_header($cell, $header, $ts) {
$ts['sort'] = 'asc';
$image = '';
}
- $cell['data'] = l($cell['data'] . $image, $_GET['q'], array('attributes' => array('title' => $title), 'query' => array_merge($ts['query'], array('sort' => $ts['sort'], 'order' => $cell['data'])), 'html' => TRUE));
+ $cell['data'] = l($cell['data'] . $image, current_path(), array('attributes' => array('title' => $title), 'query' => array_merge($ts['query'], array('sort' => $ts['sort'], 'order' => $cell['data'])), 'html' => TRUE));
unset($cell['field'], $cell['sort']);
}
@@ -193,7 +193,7 @@ function tablesort_cell($cell, $header, $ts, $i) {
* page request except for those pertaining to table sorting.
*/
function tablesort_get_query_parameters() {
- return drupal_get_query_parameters($_GET, array('q', 'sort', 'order'));
+ return drupal_get_query_parameters($_GET, array('sort', 'order'));
}
/**
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index fbb7804..fc8359b 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1734,7 +1734,7 @@ function theme_links($variables) {
// Handle links.
if (isset($link['href'])) {
- $is_current_path = ($link['href'] == $_GET['q'] || ($link['href'] == '' && drupal_is_front_page()));
+ $is_current_path = ($link['href'] == current_path() || ($link['href'] == '' && drupal_is_front_page()));
$is_current_language = (empty($link['language']) || $link['language']->langcode == $language_url->langcode);
if ($is_current_path && $is_current_language) {
$class[] = 'active';
diff --git a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
index e5722f7..1a66417 100644
--- a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
@@ -24,9 +24,6 @@ class PathSubscriber implements EventSubscriberInterface {
* @todo The path system should be objectified to remove the function calls
* in this method.
*
- * @todo We're writing back to $_GET['q'] for temporary BC. All instances of
- * $_GET['q'] should be removed and then this code eliminated.
- *
* @param GetResponseEvent $event
* The Event to process.
*/
@@ -43,14 +40,9 @@ class PathSubscriber implements EventSubscriberInterface {
$request->attributes->set('system_path', $system_path);
- // @todo Remove this line.
- // Drupal uses $_GET['q'] directly in over 100 places at present,
- // including writing back to it at times. Those are all critical bugs,
- // even by Drupal 7 standards, but as many of the places that it does so
- // are slated to be rewritten anyway we will save time and include this
- // temporary hack. Removal of this line is a critical, Drupal-release
- // blocking bug.
- $_GET['q'] = $system_path;
+ // @todo Remove this after refactoring current_path() to use the Request
+ // object.
+ _current_path($system_path);
}
/**
diff --git a/core/misc/ajax.js b/core/misc/ajax.js
index 652b8e2..f017b1e 100644
--- a/core/misc/ajax.js
+++ b/core/misc/ajax.js
@@ -120,16 +120,12 @@ Drupal.ajax = function (base, element, element_settings) {
// Replacing 'nojs' with 'ajax' in the URL allows for an easy method to let
// the server detect when it needs to degrade gracefully.
- // There are five scenarios to check for:
+ // There are four scenarios to check for:
// 1. /nojs/
// 2. /nojs$ - The end of a URL string.
- // 3. /nojs? - Followed by a query (with clean URLs enabled).
- // E.g.: path/nojs?destination=foobar
- // 4. /nojs& - Followed by a query (without clean URLs enabled).
- // E.g.: ?q=path/nojs&destination=foobar
- // 5. /nojs# - Followed by a fragment.
- // E.g.: path/nojs#myfragment
- this.url = element_settings.url.replace(/\/nojs(\/|$|\?|&|#)/g, '/ajax$1');
+ // 3. /nojs? - Followed by a query (e.g. path/nojs?destination=foobar).
+ // 4. /nojs# - Followed by a fragment (e.g.: path/nojs#myfragment).
+ this.url = element_settings.url.replace(/\/nojs(\/|$|\?|#)/g, '/ajax$1');
this.wrapper = '#' + element_settings.wrapper;
// If there isn't a form, jQuery.ajax() will be used instead, allowing us to
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index b13a852..a0b455b 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -829,13 +829,10 @@ function block_block_list_alter(&$blocks) {
// with different case. Ex: /Page, /page, /PAGE.
$pages = drupal_strtolower($block->pages);
if ($block->visibility < BLOCK_VISIBILITY_PHP) {
- // Convert the Drupal path to lowercase
- $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
- // Compare the lowercase internal and lowercase path alias (if any).
- $page_match = drupal_match_path($path, $pages);
- if ($path != $_GET['q']) {
- $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
- }
+ // Compare the lowercase path alias (if any) and internal path.
+ $path = current_path();
+ $path_alias = drupal_strtolower(drupal_get_path_alias($path));
+ $page_match = drupal_match_path($path_alias, $pages) || (($path != $path_alias) && drupal_match_path($path, $pages));
// When $block->visibility has a value of 0 (BLOCK_VISIBILITY_NOTLISTED),
// the block is displayed on all pages except those listed in $block->pages.
// When set to 1 (BLOCK_VISIBILITY_LISTED), it is displayed only on those
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 0af91ea..f0f6d54 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -503,12 +503,10 @@ function comment_permalink($cid) {
// Find the current display page for this comment.
$page = comment_get_display_page($comment->cid, $node->type);
- // Set $_GET['q'] and $_GET['page'] ourselves so that the node callback
- // behaves as it would when visiting the page directly.
- $_GET['q'] = 'node/' . $node->nid;
- $_GET['page'] = $page;
-
// Return the node view, this will show the correct comment in context.
+ // @todo Refactor to use Symfony's Request object.
+ _current_path('node/' . $node->nid);
+ $_GET['page'] = $page;
return menu_execute_active_handler('node/' . $node->nid, FALSE);
}
drupal_not_found();
diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module
index 4420e50..243157b 100644
--- a/core/modules/contact/contact.module
+++ b/core/modules/contact/contact.module
@@ -182,7 +182,7 @@ function contact_mail($key, &$message, $params) {
'!site-name' => variable_get('site_name', 'Drupal'),
'!subject' => $params['subject'],
'!category' => isset($params['category']['category']) ? $params['category']['category'] : '',
- '!form-url' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language)),
+ '!form-url' => url(current_path(), array('absolute' => TRUE, 'language' => $language)),
'!sender-name' => user_format_name($params['sender']),
'!sender-url' => $params['sender']->uid ? url('user/' . $params['sender']->uid, array('absolute' => TRUE, 'language' => $language)) : $params['sender']->mail,
);
diff --git a/core/modules/image/image.test b/core/modules/image/image.test
index 7a4683b..2a1eece 100644
--- a/core/modules/image/image.test
+++ b/core/modules/image/image.test
@@ -197,7 +197,7 @@ class ImageStylesPathAndUrlUnitTest extends DrupalWebTestCase {
$generate_url = image_style_url($this->style_name, $original_uri);
if (!$clean_url) {
- $this->assertTrue(strpos($generate_url, '?q=') !== FALSE, 'When using non-clean URLS, the system path contains the query string.');
+ $this->assertTrue(strpos($generate_url, 'index.php/') !== FALSE, 'When using non-clean URLS, the system path contains the script name.');
}
// Fetch the URL that generates the file.
diff --git a/core/modules/locale/locale.admin.inc b/core/modules/locale/locale.admin.inc
index 321b8ce..2c1c778 100644
--- a/core/modules/locale/locale.admin.inc
+++ b/core/modules/locale/locale.admin.inc
@@ -264,7 +264,7 @@ function language_negotiation_configure_url_form($form, &$form_state) {
'#title' => t('%language (%langcode) path prefix', array('%language' => $language->name, '%langcode' => $language->langcode)),
'#maxlength' => 64,
'#default_value' => isset($prefixes[$langcode]) ? $prefixes[$langcode] : '',
- '#field_prefix' => url('', array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
+ '#field_prefix' => url('', array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : 'index.php/')
);
$form['domain'][$langcode] = array(
'#type' => 'textfield',
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index e942d0d..0c499c7 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -189,7 +189,7 @@ function locale_init() {
// in $conf. This should happen on all pages except the date and time formats
// settings page, where we want to display the site default and not the
// localized version.
- if (strpos($_GET['q'], 'admin/config/regional/date-time/formats') !== 0) {
+ if (strpos(current_path(), 'admin/config/regional/date-time/formats') !== 0) {
$languages = array($language_interface->langcode);
// Setup appropriate date formats for this locale.
@@ -921,7 +921,7 @@ function locale_block_info() {
*/
function locale_block_view($type) {
if (language_multilingual()) {
- $path = drupal_is_front_page() ? '' : $_GET['q'];
+ $path = drupal_is_front_page() ? '' : current_path();
$links = language_negotiation_get_switch_links($type, $path);
if (isset($links->links)) {
diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test
index fdfbe63..48b1a73 100644
--- a/core/modules/locale/locale.test
+++ b/core/modules/locale/locale.test
@@ -1880,7 +1880,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
// Test that both node titles link to our path alias.
$this->drupalGet('');
- $custom_path_url = base_path() . (variable_get('clean_url', 0) ? $custom_path : '?q=' . $custom_path);
+ $custom_path_url = base_path() . (variable_get('clean_url', 0) ? $custom_path : 'index.php/' . $custom_path);
$elements = $this->xpath('//a[@href=:href and .=:title]', array(':href' => $custom_path_url, ':title' => $first_node->title));
$this->assertTrue(!empty($elements), t('First node links to the path alias.'));
$elements = $this->xpath('//a[@href=:href and .=:title]', array(':href' => $custom_path_url, ':title' => $second_node->title));
@@ -2370,7 +2370,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
// Check that the language switcher active link matches the given browser
// language.
- $args = array(':url' => base_path() . (!empty($GLOBALS['conf']['clean_url']) ? $langcode_browser_fallback : "?q=$langcode_browser_fallback"));
+ $args = array(':url' => base_path() . (!empty($GLOBALS['conf']['clean_url']) ? $langcode_browser_fallback : "index.php/$langcode_browser_fallback"));
$fields = $this->xpath('//div[@id="block-locale-language-interface"]//a[@class="language-link active" and @href=:url]', $args);
$this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, t('The browser language is the URL active language'));
@@ -2406,10 +2406,10 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
$this->drupalPost('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
// Build the link we're going to test based on the clean url setting.
- $link = (!empty($GLOBALS['conf']['clean_url'])) ? 'it.example.com/admin' : 'it.example.com/?q=admin';
+ $link = (!empty($GLOBALS['conf']['clean_url'])) ? 'it.example.com/admin' : 'it.example.com/index.php/admin';
global $is_https;
- // Test URL in another language: http://it.example.com/?q=admin.
+ // Test URL in another language: http://it.example.com/index.php/admin.
// Base path gives problems on the testbot, so $correct_link is hard-coded.
// @see UrlAlterFunctionalTest::assertUrlOutboundAlter (path.test).
$italian_url = url('admin', array('language' => $languages['it']));
@@ -2501,7 +2501,7 @@ class LocaleUrlRewritingTest extends DrupalWebTestCase {
private function checkUrl($language, $message1, $message2) {
$options = array('language' => $language);
$base_path = trim(base_path(), '/');
- $rewritten_path = trim(str_replace(array('?q=', $base_path), '', url('node', $options)), '/');
+ $rewritten_path = trim(str_replace(array('index.php/', $base_path), '', url('node', $options)), '/');
$segments = explode('/', $rewritten_path, 2);
$prefix = $segments[0];
$path = isset($segments[1]) ? $segments[1] : $prefix;
diff --git a/core/modules/overlay/overlay-parent.js b/core/modules/overlay/overlay-parent.js
index dd7b7ae..6c5a3d0 100644
--- a/core/modules/overlay/overlay-parent.js
+++ b/core/modules/overlay/overlay-parent.js
@@ -748,10 +748,8 @@ Drupal.overlay.fragmentizeLink = function (link, parentLocation) {
return link.href;
}
- // Determine the link's original destination. Set ignorePathFromQueryString to
- // true to prevent transforming this link into a clean URL while clean URLs
- // may be disabled.
- var path = this.getPath(link, true);
+ // Determine the link's original destination.
+ var path = this.getPath(link);
// Preserve existing query and fragment parameters in the URL, except for
// "render=overlay" which is re-added in Drupal.overlay.eventhandlerOperateByURLFragment.
var destination = path + link.search.replace(/&?render=overlay/, '').replace(/\?$/, '') + link.hash;
@@ -818,13 +816,11 @@ Drupal.overlay.resetActiveClass = function(activePath) {
*
* @param link
* Link object or string to get the Drupal path from.
- * @param ignorePathFromQueryString
- * Boolean whether to ignore path from query string if path appears empty.
*
* @return
* The Drupal path.
*/
-Drupal.overlay.getPath = function (link, ignorePathFromQueryString) {
+Drupal.overlay.getPath = function (link) {
if (typeof link == 'string') {
// Create a native Link object, so we can use its object methods.
link = $(link.link(link)).get(0);
@@ -836,14 +832,6 @@ Drupal.overlay.getPath = function (link, ignorePathFromQueryString) {
path = '/' + path;
}
path = path.replace(new RegExp(Drupal.settings.basePath + '(?:index.php)?'), '');
- if (path == '' && !ignorePathFromQueryString) {
- // If the path appears empty, it might mean the path is represented in the
- // query string (clean URLs are not used).
- var match = new RegExp('([?&])q=(.+)([]|$)').exec(link.search);
- if (match && match.length == 4) {
- path = match[2];
- }
- }
return path;
};
diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module
index 8f62c01..aec7a08 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -143,7 +143,7 @@ function overlay_init() {
// If this page shouldn't be rendered inside the overlay, redirect to the
// parent.
elseif (!path_is_admin($current_path)) {
- overlay_close_dialog($current_path, array('query' => drupal_get_query_parameters(NULL, array('q', 'render'))));
+ overlay_close_dialog($current_path, array('query' => drupal_get_query_parameters(NULL, array('render'))));
}
// Indicate that we are viewing an overlay child page.
diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc
index 511c26d..3e874ed 100644
--- a/core/modules/path/path.admin.inc
+++ b/core/modules/path/path.admin.inc
@@ -117,7 +117,7 @@ function path_admin_form($form, &$form_state, $path = array('source' => '', 'ali
'#maxlength' => 255,
'#size' => 45,
'#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'),
- '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
+ '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : 'index.php/'),
'#required' => TRUE,
);
$form['alias'] = array(
@@ -127,7 +127,7 @@ function path_admin_form($form, &$form_state, $path = array('source' => '', 'ali
'#maxlength' => 255,
'#size' => 45,
'#description' => t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
- '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
+ '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : 'index.php/'),
'#required' => TRUE,
);
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index f36d5d7..fe2a68e 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -240,7 +240,7 @@ function search_menu() {
}
/**
- * Determines access for the ?q=search path.
+ * Determines access for the search path.
*/
function search_is_active() {
// This path cannot be accessed if there are no active modules.
diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc
index 75c12b4..e181d12 100644
--- a/core/modules/shortcut/shortcut.admin.inc
+++ b/core/modules/shortcut/shortcut.admin.inc
@@ -489,7 +489,7 @@ function _shortcut_link_form_elements($shortcut_link = NULL) {
'#title' => t('Path'),
'#size' => 40,
'#maxlength' => 255,
- '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
+ '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : 'index.php/'),
'#default_value' => $shortcut_link['link_path'],
);
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index d450a20..bb57a16 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -684,7 +684,7 @@ function shortcut_preprocess_page(&$variables) {
// we do not want to display it on "access denied" or "page not found"
// pages).
if (shortcut_set_edit_access() && ($item = menu_get_item()) && $item['access']) {
- $link = $_GET['q'];
+ $link = current_path();
$query_parameters = drupal_get_query_parameters();
if (!empty($query_parameters)) {
$link .= '?' . drupal_http_build_query($query_parameters);
diff --git a/core/modules/simpletest/tests/common.test b/core/modules/simpletest/tests/common.test
index 353ab1c..1d0adea 100644
--- a/core/modules/simpletest/tests/common.test
+++ b/core/modules/simpletest/tests/common.test
@@ -97,7 +97,7 @@ class CommonURLUnitTestCase extends DrupalWebTestCase {
* Tests for active class in l() function.
*/
function testLActiveClass() {
- $link = l($this->randomName(), $_GET['q']);
+ $link = l($this->randomName(), current_path());
$this->assertTrue($this->hasClass($link, 'active'), t('Class @class is present on link to the current page', array('@class' => 'active')));
}
@@ -106,7 +106,7 @@ class CommonURLUnitTestCase extends DrupalWebTestCase {
*/
function testLCustomClass() {
$class = $this->randomName();
- $link = l($this->randomName(), $_GET['q'], array('attributes' => array('class' => array($class))));
+ $link = l($this->randomName(), current_path(), array('attributes' => array('class' => array($class))));
$this->assertTrue($this->hasClass($link, $class), t('Custom class @class is present on link when requested', array('@class' => $class)));
$this->assertTrue($this->hasClass($link, 'active'), t('Class @class is present on link to the current page', array('@class' => 'active')));
}
@@ -128,19 +128,8 @@ class CommonURLUnitTestCase extends DrupalWebTestCase {
),
),
'c' => 3,
- 'q' => 'foo/bar',
);
- // Default arguments.
- $result = $_GET;
- unset($result['q']);
- $this->assertEqual(drupal_get_query_parameters(), $result, t("\$_GET['q'] was removed."));
-
- // Default exclusion.
- $result = $original;
- unset($result['q']);
- $this->assertEqual(drupal_get_query_parameters($original), $result, t("'q' was removed."));
-
// First-level exclusion.
$result = $original;
unset($result['b']);
@@ -217,24 +206,6 @@ class CommonURLUnitTestCase extends DrupalWebTestCase {
);
$this->assertEqual(drupal_parse_url($url), $result, t('External URL parsed correctly.'));
- // Verify proper parsing of URLs when clean URLs are disabled.
- $result = array(
- 'path' => 'foo/bar',
- 'query' => array('bar' => 'baz'),
- 'fragment' => 'foo',
- );
- // Non-clean URLs #1: Absolute URL generated by url().
- $url = $GLOBALS['base_url'] . '/?q=foo/bar&bar=baz#foo';
- $this->assertEqual(drupal_parse_url($url), $result, t('Absolute URL with clean URLs disabled parsed correctly.'));
-
- // Non-clean URLs #2: Relative URL generated by url().
- $url = '?q=foo/bar&bar=baz#foo';
- $this->assertEqual(drupal_parse_url($url), $result, t('Relative URL with clean URLs disabled parsed correctly.'));
-
- // Non-clean URLs #3: URL generated by url() on non-Apache webserver.
- $url = 'index.php?q=foo/bar&bar=baz#foo';
- $this->assertEqual(drupal_parse_url($url), $result, t('Relative URL on non-Apache webserver with clean URLs disabled parsed correctly.'));
-
// Test that drupal_parse_url() does not allow spoofing a URL to force a malicious redirect.
$parts = drupal_parse_url('forged:http://cwe.mitre.org/data/definitions/601.html');
$this->assertFalse(valid_url($parts['path'], TRUE), t('drupal_parse_url() correctly parsed a forged URL.'));
@@ -252,41 +223,6 @@ class CommonURLUnitTestCase extends DrupalWebTestCase {
$base = $absolute ? $base_url . '/' : base_path();
$absolute_string = $absolute ? 'absolute' : NULL;
- // Disable Clean URLs.
- $GLOBALS['conf']['clean_url'] = 0;
-
- $url = $base . '?q=node/123';
- $result = url('node/123', array('absolute' => $absolute));
- $this->assertEqual($url, $result, "$url == $result");
-
- $url = $base . '?q=node/123#foo';
- $result = url('node/123', array('fragment' => 'foo', 'absolute' => $absolute));
- $this->assertEqual($url, $result, "$url == $result");
-
- $url = $base . '?q=node/123&foo';
- $result = url('node/123', array('query' => array('foo' => NULL), 'absolute' => $absolute));
- $this->assertEqual($url, $result, "$url == $result");
-
- $url = $base . '?q=node/123&foo=bar&bar=baz';
- $result = url('node/123', array('query' => array('foo' => 'bar', 'bar' => 'baz'), 'absolute' => $absolute));
- $this->assertEqual($url, $result, "$url == $result");
-
- $url = $base . '?q=node/123&foo#bar';
- $result = url('node/123', array('query' => array('foo' => NULL), 'fragment' => 'bar', 'absolute' => $absolute));
- $this->assertEqual($url, $result, "$url == $result");
-
- $url = $base . '?q=node/123&foo#0';
- $result = url('node/123', array('query' => array('foo' => NULL), 'fragment' => '0', 'absolute' => $absolute));
- $this->assertEqual($url, $result, "$url == $result");
-
- $url = $base . '?q=node/123&foo';
- $result = url('node/123', array('query' => array('foo' => NULL), 'fragment' => '', 'absolute' => $absolute));
- $this->assertEqual($url, $result, "$url == $result");
-
- $url = $base;
- $result = url('', array('absolute' => $absolute));
- $this->assertEqual($url, $result, "$url == $result");
-
// Enable Clean URLs.
$GLOBALS['conf']['clean_url'] = 1;
@@ -1919,8 +1855,8 @@ class CommonValidUrlUnitTestCase extends DrupalUnitTestCase {
'example.com/index.html#pagetop',
'example.com:8080',
'subdomain.example.com',
- 'example.com/index.php?q=node',
- 'example.com/index.php?q=node¶m=false',
+ 'example.com/index.php/node',
+ 'example.com/index.php/node?param=false',
'user@www.example.com',
'user:pass@www.example.com:8080/login.php?do=login&style=%23#pagetop',
'127.0.0.1',
@@ -1967,8 +1903,8 @@ class CommonValidUrlUnitTestCase extends DrupalUnitTestCase {
$valid_relative_urls = array(
'paren(the)sis',
'index.html#pagetop',
- 'index.php?q=node',
- 'index.php?q=node¶m=false',
+ 'index.php/node',
+ 'index.php/node?param=false',
'login.php?do=login&style=%23#pagetop',
);
diff --git a/core/modules/simpletest/tests/file.test b/core/modules/simpletest/tests/file.test
index a186360..b3bcec2 100644
--- a/core/modules/simpletest/tests/file.test
+++ b/core/modules/simpletest/tests/file.test
@@ -2409,7 +2409,7 @@ class FileDownloadTest extends FileTestCase {
$this->checkUrl('public', '', $basename, $base_url . '/' . file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . $basename_encoded);
$this->checkUrl('private', '', $basename, $base_url . '/system/files/' . $basename_encoded);
- $this->checkUrl('private', '', $basename, $base_url . '/?q=system/files/' . $basename_encoded, '0');
+ $this->checkUrl('private', '', $basename, $base_url . '/index.php/system/files/' . $basename_encoded, '0');
}
/**
diff --git a/core/modules/simpletest/tests/menu.test b/core/modules/simpletest/tests/menu.test
index 5a173b1..7d5eacb 100644
--- a/core/modules/simpletest/tests/menu.test
+++ b/core/modules/simpletest/tests/menu.test
@@ -244,11 +244,11 @@ class MenuRouterTestCase extends DrupalWebTestCase {
$this->DrupalGet('user/login');
// Check that we got to 'user'.
- $this->assertTrue($this->url == url('user', array('absolute' => TRUE)), t("Logged-in user redirected to q=user on accessing q=user/login"));
+ $this->assertTrue($this->url == url('user', array('absolute' => TRUE)), t("Logged-in user redirected to user on accessing user/login"));
// user/register should redirect to user/UID/edit.
$this->DrupalGet('user/register');
- $this->assertTrue($this->url == url('user/' . $this->loggedInUser->uid . '/edit', array('absolute' => TRUE)), t("Logged-in user redirected to q=user/UID/edit on accessing q=user/register"));
+ $this->assertTrue($this->url == url('user/' . $this->loggedInUser->uid . '/edit', array('absolute' => TRUE)), t("Logged-in user redirected to user/UID/edit on accessing user/register"));
}
/**
diff --git a/core/modules/simpletest/tests/menu_test.module b/core/modules/simpletest/tests/menu_test.module
index 6e2114d..963574d 100644
--- a/core/modules/simpletest/tests/menu_test.module
+++ b/core/modules/simpletest/tests/menu_test.module
@@ -516,7 +516,7 @@ function menu_test_static_variable($value = NULL) {
* Implements hook_menu_site_status_alter().
*/
function menu_test_menu_site_status_alter(&$menu_site_status, $path) {
- // Allow access to ?q=menu_login_callback even if in maintenance mode.
+ // Allow access to menu_login_callback even if in maintenance mode.
if ($menu_site_status == MENU_SITE_OFFLINE && $path == 'menu_login_callback') {
$menu_site_status = MENU_SITE_ONLINE;
}
diff --git a/core/modules/simpletest/tests/path.test b/core/modules/simpletest/tests/path.test
index 308ef64..3102469 100644
--- a/core/modules/simpletest/tests/path.test
+++ b/core/modules/simpletest/tests/path.test
@@ -201,11 +201,11 @@ class UrlAlterFunctionalTest extends DrupalWebTestCase {
}
/**
- * Tests that $_GET['q'] is initialized when the request path is empty.
+ * Tests that current_path() 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.");
+ $this->assertText("current_path() is non-empty with an empty request path.", "current_path() is initialized with an empty request path.");
}
/**
@@ -221,7 +221,7 @@ class UrlAlterFunctionalTest extends DrupalWebTestCase {
protected function assertUrlOutboundAlter($original, $final) {
// Test outbound altering.
$result = url($original);
- $base_path = base_path() . (variable_get('clean_url', '0') ? '' : '?q=');
+ $base_path = base_path() . (variable_get('clean_url', '0') ? '' : 'index.php/');
$result = substr($result, strlen($base_path));
$this->assertIdentical($result, $final, t('Altered outbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
}
diff --git a/core/modules/simpletest/tests/tablesort.test b/core/modules/simpletest/tests/tablesort.test
index 9c068f8..aaea505 100644
--- a/core/modules/simpletest/tests/tablesort.test
+++ b/core/modules/simpletest/tests/tablesort.test
@@ -49,7 +49,7 @@ class TableSortTest extends DrupalUnitTestCase {
$headers = array('foo', 'bar', 'baz');
// Reset $_GET to prevent parameters from Simpletest and Batch API ending
// up in $ts['query'].
- $_GET = array('q' => 'jahwohl');
+ $_GET = array();
$expected_ts = array(
'name' => 'foo',
'sql' => '',
@@ -64,7 +64,6 @@ class TableSortTest extends DrupalUnitTestCase {
// override the default.
$_GET = array(
- 'q' => 'jahwohl',
// This should not override the table order because only complex
// headers are overridable.
'order' => 'bar',
@@ -77,7 +76,6 @@ class TableSortTest extends DrupalUnitTestCase {
// override the default.
$_GET = array(
- 'q' => 'jahwohl',
'sort' => 'DESC',
// Add an unrelated parameter to ensure that tablesort will include
// it in the links that it creates.
@@ -107,7 +105,6 @@ class TableSortTest extends DrupalUnitTestCase {
);
// Reset $_GET from previous assertion.
$_GET = array(
- 'q' => 'jahwohl',
'order' => '2',
);
$ts = tablesort_init($headers);
@@ -124,7 +121,6 @@ class TableSortTest extends DrupalUnitTestCase {
// override the default.
$_GET = array(
- 'q' => 'jahwohl',
// This should not override the table order because this header does not
// exist.
'order' => 'bar',
@@ -144,7 +140,6 @@ class TableSortTest extends DrupalUnitTestCase {
// override the default.
$_GET = array(
- 'q' => 'jahwohl',
'order' => '1',
'sort' => 'ASC',
// Add an unrelated parameter to ensure that tablesort will include
diff --git a/core/modules/simpletest/tests/theme.test b/core/modules/simpletest/tests/theme.test
index a795054..e060610 100644
--- a/core/modules/simpletest/tests/theme.test
+++ b/core/modules/simpletest/tests/theme.test
@@ -71,14 +71,14 @@ class ThemeUnitTest extends DrupalWebTestCase {
* Ensure page-front template suggestion is added when on front page.
*/
function testFrontPageThemeSuggestion() {
- $q = $_GET['q'];
- // Set $_GET['q'] to node because theme_get_suggestions() will query it to
- // see if we are on the front page.
+ $original_path = _current_path();
+ // Set the current path to node because theme_get_suggestions() will query
+ // it to see if we are on the front page.
variable_set('site_frontpage', 'node');
- $_GET['q'] = 'node';
- $suggestions = theme_get_suggestions(explode('/', $_GET['q']), 'page');
+ _current_path('node');
+ $suggestions = theme_get_suggestions(array('node'), 'page');
// Set it back to not annoy the batch runner.
- $_GET['q'] = $q;
+ _current_path($original_path);
$this->assertTrue(in_array('page__front', $suggestions), t('Front page template was suggested.'));
}
@@ -308,7 +308,7 @@ class ThemeFunctionsTestCase extends DrupalWebTestCase {
// Required to verify the "active" class in expected links below, and
// because the current path is different when running tests manually via
// simpletest.module ('batch') and via the testing framework ('').
- $_GET['q'] = variable_get('site_frontpage', 'user');
+ _current_path(variable_get('site_frontpage', 'user'));
// Verify that a list of links is properly rendered.
$variables = array();
diff --git a/core/modules/simpletest/tests/url_alter_test.module b/core/modules/simpletest/tests/url_alter_test.module
index 9287ff5..e33029c 100644
--- a/core/modules/simpletest/tests/url_alter_test.module
+++ b/core/modules/simpletest/tests/url_alter_test.module
@@ -30,8 +30,8 @@ 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.");
+ if (!request_path() && !current_path()) {
+ drupal_set_message("current_path() is non-empty with an empty request path.");
}
// Rewrite user/username to user/uid.
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index 73d6232..38f9bcd 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -82,7 +82,7 @@ function statistics_exit() {
db_insert('accesslog')
->fields(array(
'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
- 'path' => truncate_utf8($_GET['q'], 255),
+ 'path' => truncate_utf8(current_path(), 255),
'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
'hostname' => ip_address(),
'uid' => $user->uid,
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index a45a0e3..65db148 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -1493,7 +1493,7 @@ function system_site_information_settings() {
'#default_value' => (variable_get('site_frontpage') != 'user' ? drupal_get_path_alias(variable_get('site_frontpage', 'user')) : ''),
'#size' => 40,
'#description' => t('Optionally, specify a relative URL to display as the front page. Leave blank to display the default content feed.'),
- '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
+ '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : 'index.php/'),
);
$form['front_page']['default_nodes_main'] = array(
'#type' => 'select', '#title' => t('Number of posts on front page'),
@@ -1512,7 +1512,7 @@ function system_site_information_settings() {
'#default_value' => variable_get('site_403', ''),
'#size' => 40,
'#description' => t('This page is displayed when the requested document is denied to the current user. Leave blank to display a generic "access denied" page.'),
- '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
+ '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : 'index.php/')
);
$form['error_page']['site_404'] = array(
'#type' => 'textfield',
@@ -1520,7 +1520,7 @@ function system_site_information_settings() {
'#default_value' => variable_get('site_404', ''),
'#size' => 40,
'#description' => t('This page is displayed when no other content matches the requested document. Leave blank to display a generic "page not found" page.'),
- '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
+ '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : 'index.php/')
);
$form['#validate'][] = 'system_site_information_settings_validate';
@@ -2206,96 +2206,6 @@ function system_site_maintenance_mode() {
}
/**
- * Form builder; Configure clean URL settings.
- *
- * @ingroup forms
- * @see system_settings_form()
- */
-function system_clean_url_settings($form, &$form_state) {
- $available = FALSE;
- $conflict = FALSE;
-
- // If the request URI is a clean URL, clean URLs must be available.
- // Otherwise, run a test.
- if (strpos(request_uri(), '?q=') === FALSE && strpos(request_uri(), '&q=') === FALSE) {
- $available = TRUE;
- }
- else {
- $request = drupal_http_request($GLOBALS['base_url'] . '/admin/config/search/clean-urls/check');
- // If the request returns HTTP 200, clean URLs are available.
- if (isset($request->code) && $request->code == 200) {
- $available = TRUE;
- // If the user started the clean URL test, provide explicit feedback.
- if (isset($form_state['input']['clean_url_test_execute'])) {
- drupal_set_message(t('The clean URL test passed.'));
- }
- }
- else {
- // If the test failed while clean URLs are enabled, make sure clean URLs
- // can be disabled.
- if (variable_get('clean_url', 0)) {
- $conflict = TRUE;
- // Warn the user of a conflicting situation, unless after processing
- // a submitted form.
- if (!isset($form_state['input']['op'])) {
- drupal_set_message(t('Clean URLs are enabled, but the clean URL test failed. Uncheck the box below to disable clean URLs.'), 'warning');
- }
- }
- // If the user started the clean URL test, provide explicit feedback.
- elseif (isset($form_state['input']['clean_url_test_execute'])) {
- drupal_set_message(t('The clean URL test failed.'), 'warning');
- }
- }
- }
-
- // Show the enable/disable form if clean URLs are available or if the user
- // must be able to resolve a conflicting setting.
- if ($available || $conflict) {
- $form['clean_url'] = array(
- '#type' => 'checkbox',
- '#title' => t('Enable clean URLs'),
- '#default_value' => variable_get('clean_url', 0),
- '#description' => t('Use URLs like example.com/user
instead of example.com/?q=user
.'),
- );
- $form = system_settings_form($form);
- if ($conflict) {
- // $form_state['redirect'] needs to be set to the non-clean URL,
- // otherwise the setting is not saved.
- $form_state['redirect'] = url('', array('query' => array('q' => '/admin/config/search/clean-urls')));
- }
- }
- // Show the clean URLs test form.
- else {
- drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
-
- $form_state['redirect'] = url('admin/config/search/clean-urls');
- $form['clean_url_description'] = array(
- '#type' => 'markup',
- '#markup' => '' . t('Use URLs like example.com/user
instead of example.com/?q=user
.'),
- );
- // Explain why the user is seeing this page and what to expect after
- // clicking the 'Run the clean URL test' button.
- $form['clean_url_test_result'] = array(
- '#type' => 'markup',
- '#markup' => '
' . t('Clean URLs cannot be enabled. If you are directed to this page or to a Page not found (404) error after testing for clean URLs, see the online handbook.', array('@handbook' => 'http://drupal.org/node/15365')) . '
',
- );
- $form['actions'] = array(
- '#type' => 'actions',
- 'clean_url_test' => array(
- '#type' => 'submit',
- '#value' => t('Run the clean URL test'),
- ),
- );
- $form['clean_url_test_execute'] = array(
- '#type' => 'hidden',
- '#value' => 1,
- );
- }
-
- return $form;
-}
-
-/**
* Menu callback: displays the site status report. Can also be used as a pure check.
*
* @param $check
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 907b7b5..08c3da6 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -486,7 +486,7 @@ function hook_page_build(&$page) {
*/
function hook_menu_get_item_alter(&$router_item, $path, $original_map) {
// When retrieving the router item for the current path...
- if ($path == $_GET['q']) {
+ if ($path == current_path()) {
// ...call a function that prepares something for this request.
mymodule_prepare_something();
}
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index bdaf966..497eb86 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -933,23 +933,6 @@ function system_menu() {
'access arguments' => array('access administration pages'),
'file' => 'system.admin.inc',
);
- $items['admin/config/search/clean-urls'] = array(
- 'title' => 'Clean URLs',
- 'description' => 'Enable or disable clean URLs for your site.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('system_clean_url_settings'),
- 'access arguments' => array('administer site configuration'),
- 'file' => 'system.admin.inc',
- 'weight' => 5,
- );
- $items['admin/config/search/clean-urls/check'] = array(
- 'title' => 'Clean URL check',
- 'page callback' => 'drupal_json_output',
- 'page arguments' => array(array('status' => TRUE)),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
- 'file' => 'system.admin.inc',
- );
// System settings.
$items['admin/config/system'] = array(
diff --git a/core/modules/system/system.test b/core/modules/system/system.test
index 64774c4..ec52ddc 100644
--- a/core/modules/system/system.test
+++ b/core/modules/system/system.test
@@ -2679,11 +2679,8 @@ class SystemIndexPhpTest extends DrupalWebTestCase {
$this->drupalGet($index_php, array('external' => TRUE));
$this->assertResponse(200, t('Make sure index.php returns a valid page.'));
- $this->drupalGet($index_php, array('external' => TRUE, 'query' => array('q' => 'user')));
- $this->assertResponse(200, t('Make sure index.php?q=user returns a valid page.'));
-
$this->drupalGet($index_php .'/user', array('external' => TRUE));
- $this->assertResponse(404, t("Make sure index.php/user returns a 'page not found'."));
+ $this->assertResponse(200, t("Make sure index.php/user returns a valid page."));
}
}
/**
diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc
index beb87f9..d39cc87 100644
--- a/core/modules/taxonomy/taxonomy.admin.inc
+++ b/core/modules/taxonomy/taxonomy.admin.inc
@@ -424,7 +424,7 @@ function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
'#type' => 'submit',
'#value' => t('Reset to alphabetical')
);
- $form_state['redirect'] = array($_GET['q'], (isset($_GET['page']) ? array('query' => array('page' => $_GET['page'])) : array()));
+ $form_state['redirect'] = array(current_path(), (isset($_GET['page']) ? array('query' => array('page' => $_GET['page'])) : array()));
}
return $form;
@@ -785,7 +785,7 @@ function taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary =
);
}
else {
- $form_state['redirect'] = $_GET['q'];
+ $form_state['redirect'] = current_path();
}
return $form;
diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc
index 2ccd97c..02247f4 100644
--- a/core/modules/update/update.compare.inc
+++ b/core/modules/update/update.compare.inc
@@ -739,7 +739,6 @@ function update_project_cache($cid) {
// On certain paths, we should clear the cache and recompute the projects for
// update status of the site to avoid presenting stale information.
- $q = $_GET['q'];
$paths = array(
'admin/modules',
'admin/modules/update',
@@ -751,7 +750,7 @@ function update_project_cache($cid) {
'admin/reports/status',
'admin/reports/updates/check',
);
- if (in_array($q, $paths)) {
+ if (in_array(current_path(), $paths)) {
_update_cache_clear($cid);
}
else {
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index 020f026..cec89f2 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -107,7 +107,7 @@ function update_help($path, $arg) {
*/
function update_init() {
if (arg(0) == 'admin' && user_access('administer site configuration')) {
- switch ($_GET['q']) {
+ switch (current_path()) {
// These pages don't need additional nagging.
case 'admin/appearance/update':
case 'admin/appearance/install':
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 630c4b5..0f3a467 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -1179,7 +1179,7 @@ function user_user_presave(&$edit, $account) {
}
function user_login_block($form) {
- $form['#action'] = url($_GET['q'], array('query' => drupal_get_destination()));
+ $form['#action'] = url(current_path(), array('query' => drupal_get_destination()));
$form['#id'] = 'user-login-form';
$form['#validate'] = user_login_default_validators();
$form['#submit'][] = 'user_login_submit';
@@ -3717,7 +3717,7 @@ function user_register_form($form, &$form_state) {
if ($admin) {
// Redirect back to page which initiated the create request;
// usually admin/people/create.
- $form_state['redirect'] = $_GET['q'];
+ $form_state['redirect'] = current_path();
}
$form['actions'] = array('#type' => 'actions');
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 5bf95fb..cc2665f 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -155,7 +155,7 @@ All arguments are long options.
One or more tests to be run. By default, these are interpreted
as the names of test groups as shown at
- ?q=admin/config/development/testing.
+ admin/config/development/testing.
These group names typically correspond to module names like "User"
or "Profile" or "System", but there is also a group "XML-RPC".
If --class is specified then these are interpreted as the names of
diff --git a/robots.txt b/robots.txt
index 90bec1e..d590fbf 100644
--- a/robots.txt
+++ b/robots.txt
@@ -35,12 +35,12 @@ Disallow: /user/password/
Disallow: /user/login/
Disallow: /user/logout/
# Paths (no clean URLs)
-Disallow: /?q=admin/
-Disallow: /?q=comment/reply/
-Disallow: /?q=filter/tips/
-Disallow: /?q=node/add/
-Disallow: /?q=search/
-Disallow: /?q=user/password/
-Disallow: /?q=user/register/
-Disallow: /?q=user/login/
-Disallow: /?q=user/logout/
+Disallow: /index.php/admin/
+Disallow: /index.php/comment/reply/
+Disallow: /index.php/filter/tips/
+Disallow: /index.php/node/add/
+Disallow: /index.php/search/
+Disallow: /index.php/user/password/
+Disallow: /index.php/user/register/
+Disallow: /index.php/user/login/
+Disallow: /index.php/user/logout/