Commit d633c857 authored by catch's avatar catch

Issue #2257395 by marcingy: URL helper functions were converted in an inconsient manner.

parent d6725d94
......@@ -344,44 +344,6 @@ function drupal_get_feeds($delimiter = "\n") {
* Functions to properly handle HTTP responses.
*/
/**
* Processes a URL query parameter array to remove unwanted elements.
*
* @param $query
* (optional) An array to be processed. Defaults to \Drupal::request()->query
* parameters.
* @param $exclude
* (optional) A list of $query array keys to remove. Use "parent[child]" to
* 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().
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal\Component\Utility\UrlHelper::filterQueryParameters().
*/
function drupal_get_query_parameters(array $query = NULL, array $exclude = array(), $parent = '') {
if (!isset($query)) {
$query = \Drupal::request()->query->all();
}
return UrlHelper::filterQueryParameters($query, $exclude, $parent);
}
/**
* Parses an array into a valid, rawurlencoded query string.
*
* @see drupal_get_query_parameters()
* @ingroup php_wrappers
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal\Component\Utility\UrlHelper::buildQuery().
*/
function drupal_http_build_query(array $query, $parent = '') {
return UrlHelper::buildQuery($query, $parent);
}
/**
* Prepares a 'destination' URL query parameter for use with url().
*
......@@ -848,23 +810,6 @@ function url($path = NULL, array $options = array()) {
return $url;
}
/**
* Returns TRUE if a path is external to Drupal (e.g. http://example.com).
*
* If a path cannot be assessed by Drupal's menu handler, then we must
* treat it as potentially insecure.
*
* @param $path
* The internal path or external URL being linked to, such as "node/34" or
* "http://example.com/foo".
*
* @return
* Boolean TRUE or FALSE, where TRUE indicates an external path.
*/
function url_is_external($path) {
return UrlHelper::isExternal($path);
}
/**
* Formats an attribute string for an HTTP header.
*
......
......@@ -907,7 +907,7 @@ function install_goto($path) {
*/
function drupal_current_script_url($query = array()) {
$uri = $_SERVER['SCRIPT_NAME'];
$query = array_merge(drupal_get_query_parameters(), $query);
$query = array_merge(UrlHelper::filterQueryParameters(\Drupal::request()->query->all()), $query);
if (!empty($query)) {
$uri .= '?' . UrlHelper::buildQuery($query);
}
......
......@@ -10,7 +10,6 @@
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
use Symfony\Component\HttpFoundation\Request;
/**
* Tests for URL generation functions.
......@@ -26,7 +25,7 @@ class UrlTest extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'URL generation tests',
'description' => 'Confirm that url(), drupal_get_query_parameters(), \Drupal\Component\Utility\UrlHelper::buildQuery(), and l() work correctly with various input.',
'description' => 'Confirm that url(), \Drupal\Component\Utility\UrlHelper::filterQueryParameters(), \Drupal\Component\Utility\UrlHelper::buildQuery(), and l() work correctly with various input.',
'group' => 'Common',
);
}
......@@ -184,7 +183,7 @@ private function hasAttribute($attribute, $link, $class) {
}
/**
* Tests drupal_get_query_parameters().
* Tests UrlHelper::filterQueryParameters().
*/
function testDrupalGetQueryParameters() {
$original = array(
......@@ -201,22 +200,22 @@ function testDrupalGetQueryParameters() {
// First-level exclusion.
$result = $original;
unset($result['b']);
$this->assertEqual(drupal_get_query_parameters($original, array('b')), $result, "'b' was removed.");
$this->assertEqual(UrlHelper::filterQueryParameters($original, array('b')), $result, "'b' was removed.");
// Second-level exclusion.
$result = $original;
unset($result['b']['d']);
$this->assertEqual(drupal_get_query_parameters($original, array('b[d]')), $result, "'b[d]' was removed.");
$this->assertEqual(UrlHelper::filterQueryParameters($original, array('b[d]')), $result, "'b[d]' was removed.");
// Third-level exclusion.
$result = $original;
unset($result['b']['e']['f']);
$this->assertEqual(drupal_get_query_parameters($original, array('b[e][f]')), $result, "'b[e][f]' was removed.");
$this->assertEqual(UrlHelper::filterQueryParameters($original, array('b[e][f]')), $result, "'b[e][f]' was removed.");
// Multiple exclusions.
$result = $original;
unset($result['a'], $result['b']['e'], $result['c']);
$this->assertEqual(drupal_get_query_parameters($original, array('a', 'b[e]', 'c')), $result, "'a', 'b[e]', 'c' were removed.");
$this->assertEqual(UrlHelper::filterQueryParameters($original, array('a', 'b[e]', 'c')), $result, "'a', 'b[e]', 'c' were removed.");
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment