Issue #2257395 by marcingy: URL helper functions were converted in an inconsient manner.
parent
d6725d94ec
commit
d633c8574b
|
@ -344,44 +344,6 @@ function drupal_get_feeds($delimiter = "\n") {
|
||||||
* Functions to properly handle HTTP responses.
|
* 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().
|
* Prepares a 'destination' URL query parameter for use with url().
|
||||||
*
|
*
|
||||||
|
@ -848,23 +810,6 @@ function url($path = NULL, array $options = array()) {
|
||||||
return $url;
|
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.
|
* Formats an attribute string for an HTTP header.
|
||||||
*
|
*
|
||||||
|
|
|
@ -907,7 +907,7 @@ function install_goto($path) {
|
||||||
*/
|
*/
|
||||||
function drupal_current_script_url($query = array()) {
|
function drupal_current_script_url($query = array()) {
|
||||||
$uri = $_SERVER['SCRIPT_NAME'];
|
$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)) {
|
if (!empty($query)) {
|
||||||
$uri .= '?' . UrlHelper::buildQuery($query);
|
$uri .= '?' . UrlHelper::buildQuery($query);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace Drupal\system\Tests\Common;
|
||||||
use Drupal\Component\Utility\UrlHelper;
|
use Drupal\Component\Utility\UrlHelper;
|
||||||
use Drupal\Core\Language\Language;
|
use Drupal\Core\Language\Language;
|
||||||
use Drupal\simpletest\WebTestBase;
|
use Drupal\simpletest\WebTestBase;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for URL generation functions.
|
* Tests for URL generation functions.
|
||||||
|
@ -26,7 +25,7 @@ class UrlTest extends WebTestBase {
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
'name' => 'URL generation tests',
|
'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',
|
'group' => 'Common',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -184,7 +183,7 @@ class UrlTest extends WebTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests drupal_get_query_parameters().
|
* Tests UrlHelper::filterQueryParameters().
|
||||||
*/
|
*/
|
||||||
function testDrupalGetQueryParameters() {
|
function testDrupalGetQueryParameters() {
|
||||||
$original = array(
|
$original = array(
|
||||||
|
@ -201,22 +200,22 @@ class UrlTest extends WebTestBase {
|
||||||
// First-level exclusion.
|
// First-level exclusion.
|
||||||
$result = $original;
|
$result = $original;
|
||||||
unset($result['b']);
|
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.
|
// Second-level exclusion.
|
||||||
$result = $original;
|
$result = $original;
|
||||||
unset($result['b']['d']);
|
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.
|
// Third-level exclusion.
|
||||||
$result = $original;
|
$result = $original;
|
||||||
unset($result['b']['e']['f']);
|
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.
|
// Multiple exclusions.
|
||||||
$result = $original;
|
$result = $original;
|
||||||
unset($result['a'], $result['b']['e'], $result['c']);
|
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.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue