Commit f17f9cf6 authored by alexpott's avatar alexpott

Revert "Issue #1998696 by kmcculloch, kim.pepper, valdo: Use Symfony Request for core includes."

This reverts commit 127b54a6.
parent 7dd31494
...@@ -235,14 +235,12 @@ function ajax_render($commands = array()) { ...@@ -235,14 +235,12 @@ function ajax_render($commands = array()) {
// during this request to be loaded by the page. We only want to send back // during this request to be loaded by the page. We only want to send back
// files that the page hasn't already loaded, so we implement simple diffing // files that the page hasn't already loaded, so we implement simple diffing
// logic using array_diff_key(). // logic using array_diff_key().
$request = Drupal::request();
foreach (array('css', 'js') as $type) { foreach (array('css', 'js') as $type) {
// It is highly suspicious if $_POST['ajax_page_state'][$type] is empty, // It is highly suspicious if $_POST['ajax_page_state'][$type] is empty,
// since the base page ought to have at least one JS file and one CSS file // since the base page ought to have at least one JS file and one CSS file
// loaded. It probably indicates an error, and rather than making the page // loaded. It probably indicates an error, and rather than making the page
// reload all of the files, instead we return no new files. // reload all of the files, instead we return no new files.
$state = $request->request->get('ajax_page_state[' . $type . ']', FALSE, TRUE); if (empty($_POST['ajax_page_state'][$type])) {
if ($state) {
$items[$type] = array(); $items[$type] = array();
} }
else { else {
...@@ -261,7 +259,7 @@ function ajax_render($commands = array()) { ...@@ -261,7 +259,7 @@ function ajax_render($commands = array()) {
} }
} }
// Ensure that the page doesn't reload what it already has. // Ensure that the page doesn't reload what it already has.
$items[$type] = array_diff_key($items[$type], $state); $items[$type] = array_diff_key($items[$type], $_POST['ajax_page_state'][$type]);
} }
} }
...@@ -319,8 +317,7 @@ function ajax_render($commands = array()) { ...@@ -319,8 +317,7 @@ function ajax_render($commands = array()) {
function ajax_get_form() { function ajax_get_form() {
$form_state = form_state_defaults(); $form_state = form_state_defaults();
$request = Drupal::request(); $form_build_id = $_POST['form_build_id'];
$form_build_id = $request->request->get('form_build_id');
// Get the form from the cache. // Get the form from the cache.
$form = form_get_cache($form_build_id, $form_state); $form = form_get_cache($form_build_id, $form_state);
...@@ -345,7 +342,7 @@ function ajax_get_form() { ...@@ -345,7 +342,7 @@ function ajax_get_form() {
// The form needs to be processed; prepare for that by setting a few internal // The form needs to be processed; prepare for that by setting a few internal
// variables. // variables.
$form_state['input'] = $request->request->all(); $form_state['input'] = $_POST;
$form_id = $form['#form_id']; $form_id = $form['#form_id'];
return array($form, $form_state, $form_id, $form_build_id); return array($form, $form_state, $form_id, $form_build_id);
...@@ -407,10 +404,10 @@ function ajax_form_callback() { ...@@ -407,10 +404,10 @@ function ajax_form_callback() {
* @see file_menu() * @see file_menu()
*/ */
function ajax_base_page_theme() { function ajax_base_page_theme() {
$request = Drupal::request(); if (!empty($_POST['ajax_page_state']['theme']) && !empty($_POST['ajax_page_state']['theme_token'])) {
$theme = $request->request->get('ajax_page_state[theme]', NULL, TRUE); $theme = $_POST['ajax_page_state']['theme'];
$token = $request->request->get('ajax_page_state[theme_token]', NULL, TRUE); $token = $_POST['ajax_page_state']['theme_token'];
if (!empty($theme) && !empty($token)) {
// Prevent a request forgery from giving a person access to a theme they // Prevent a request forgery from giving a person access to a theme they
// shouldn't be otherwise allowed to see. However, since everyone is allowed // shouldn't be otherwise allowed to see. However, since everyone is allowed
// to see the default theme, token validation isn't required for that, and // to see the default theme, token validation isn't required for that, and
......
...@@ -3989,8 +3989,7 @@ function show(&$element) { ...@@ -3989,8 +3989,7 @@ function show(&$element) {
* @see drupal_render_cache_set() * @see drupal_render_cache_set()
*/ */
function drupal_render_cache_get($elements) { function drupal_render_cache_get($elements) {
$request = Drupal::request(); if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) {
if (!$request->isMethodSafe() || !$cid = drupal_render_cid_create($elements)) {
return FALSE; return FALSE;
} }
$bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache'; $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
...@@ -4022,8 +4021,7 @@ function drupal_render_cache_get($elements) { ...@@ -4022,8 +4021,7 @@ function drupal_render_cache_get($elements) {
*/ */
function drupal_render_cache_set(&$markup, $elements) { function drupal_render_cache_set(&$markup, $elements) {
// Create the cache ID for the element. // Create the cache ID for the element.
$request = Drupal::request(); if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) {
if (!$request->isMethodSafe() || !$cid = drupal_render_cid_create($elements)) {
return FALSE; return FALSE;
} }
......
...@@ -222,8 +222,7 @@ function _drupal_log_error($error, $fatal = FALSE) { ...@@ -222,8 +222,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
} }
} }
$request = Drupal::request(); if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
if ($request->isXmlHttpRequest()) {
if ($fatal) { if ($fatal) {
if (error_displayable($error)) { if (error_displayable($error)) {
// When called from JavaScript, simply output the error message. // When called from JavaScript, simply output the error message.
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* @see pager_default_initialize() * @see pager_default_initialize()
*/ */
function pager_find_page($element = 0) { function pager_find_page($element = 0) {
$page = Drupal::request()->query->get('page', ''); $page = isset($_GET['page']) ? $_GET['page'] : '';
$page_array = explode(',', $page); $page_array = explode(',', $page);
if (!isset($page_array[$element])) { if (!isset($page_array[$element])) {
$page_array[$element] = 0; $page_array[$element] = 0;
...@@ -136,7 +136,7 @@ function pager_default_initialize($total, $limit, $element = 0) { ...@@ -136,7 +136,7 @@ function pager_default_initialize($total, $limit, $element = 0) {
function pager_get_query_parameters() { function pager_get_query_parameters() {
$query = &drupal_static(__FUNCTION__); $query = &drupal_static(__FUNCTION__);
if (!isset($query)) { if (!isset($query)) {
$query = drupal_get_query_parameters(Drupal::request()->query->all(), array('page')); $query = drupal_get_query_parameters($_GET, array('page'));
} }
return $query; return $query;
} }
...@@ -425,7 +425,7 @@ function pager_query_add_page(array $query, $element, $index) { ...@@ -425,7 +425,7 @@ function pager_query_add_page(array $query, $element, $index) {
// Determine the first result to display on the linked page. // Determine the first result to display on the linked page.
$page_new = pager_load_array($index, $element, $pager_page_array); $page_new = pager_load_array($index, $element, $pager_page_array);
$page = Drupal::request()->query->get('page', ''); $page = isset($_GET['page']) ? $_GET['page'] : '';
if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) { if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
$query['page'] = $new_page; $query['page'] = $new_page;
} }
......
...@@ -100,7 +100,7 @@ function tablesort_cell($cell, $header, $ts, $i) { ...@@ -100,7 +100,7 @@ function tablesort_cell($cell, $header, $ts, $i) {
* page request except for those pertaining to table sorting. * page request except for those pertaining to table sorting.
*/ */
function tablesort_get_query_parameters() { function tablesort_get_query_parameters() {
return drupal_get_query_parameters(Drupal::request()->query->all(), array('sort', 'order')); return drupal_get_query_parameters($_GET, array('sort', 'order'));
} }
/** /**
...@@ -115,7 +115,7 @@ function tablesort_get_query_parameters() { ...@@ -115,7 +115,7 @@ function tablesort_get_query_parameters() {
* - "sql": The name of the database field to sort on. * - "sql": The name of the database field to sort on.
*/ */
function tablesort_get_order($headers) { function tablesort_get_order($headers) {
$order = Drupal::request()->query->get('order', ''); $order = isset($_GET['order']) ? $_GET['order'] : '';
foreach ($headers as $header) { foreach ($headers as $header) {
if (is_array($header)) { if (is_array($header)) {
if (isset($header['data']) && $order == $header['data']) { if (isset($header['data']) && $order == $header['data']) {
...@@ -150,9 +150,8 @@ function tablesort_get_order($headers) { ...@@ -150,9 +150,8 @@ function tablesort_get_order($headers) {
* The current sort direction ("asc" or "desc"). * The current sort direction ("asc" or "desc").
*/ */
function tablesort_get_sort($headers) { function tablesort_get_sort($headers) {
$sort = Drupal::request()->query->get('sort'); if (isset($_GET['sort'])) {
if (isset($sort)) { return (strtolower($_GET['sort']) == 'desc') ? 'desc' : 'asc';
return (strtolower($sort) == 'desc') ? 'desc' : 'asc';
} }
// The user has not specified a sort. Use the default for the currently sorted // The user has not specified a sort. Use the default for the currently sorted
// header if specified; otherwise use "asc". // header if specified; otherwise use "asc".
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace Drupal\system\Tests\Common; namespace Drupal\system\Tests\Common;
use Drupal\simpletest\UnitTestBase; use Drupal\simpletest\UnitTestBase;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Tests unicode handling features implemented in unicode.inc. * Tests unicode handling features implemented in unicode.inc.
...@@ -54,42 +53,38 @@ function testTableSortInit() { ...@@ -54,42 +53,38 @@ function testTableSortInit() {
$headers = array('foo', 'bar', 'baz'); $headers = array('foo', 'bar', 'baz');
// Reset $_GET to prevent parameters from Simpletest and Batch API ending // Reset $_GET to prevent parameters from Simpletest and Batch API ending
// up in $ts['query']. // up in $ts['query'].
$_GET = array();
$expected_ts = array( $expected_ts = array(
'name' => 'foo', 'name' => 'foo',
'sql' => '', 'sql' => '',
'sort' => 'asc', 'sort' => 'asc',
'query' => array(), 'query' => array(),
); );
$request = Request::createFromGlobals();
$request->query->replace(array());
\Drupal::getContainer()->set('request', $request);
$ts = tablesort_init($headers); $ts = tablesort_init($headers);
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => check_plain(var_export($ts, TRUE))))); $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => check_plain(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.'); $this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.');
// Test with simple table headers plus $_GET parameters that should _not_ // Test with simple table headers plus $_GET parameters that should _not_
// override the default. // override the default.
$request = Request::createFromGlobals();
$request->query->replace(array( $_GET = array(
// This should not override the table order because only complex // This should not override the table order because only complex
// headers are overridable. // headers are overridable.
'order' => 'bar', 'order' => 'bar',
)); );
\Drupal::getContainer()->set('request', $request);
$ts = tablesort_init($headers); $ts = tablesort_init($headers);
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => check_plain(var_export($ts, TRUE))))); $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => check_plain(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.'); $this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.');
// Test with simple table headers plus $_GET parameters that _should_ // Test with simple table headers plus $_GET parameters that _should_
// override the default. // override the default.
$request = Request::createFromGlobals();
$request->query->replace(array( $_GET = array(
'sort' => 'DESC', 'sort' => 'DESC',
// Add an unrelated parameter to ensure that tablesort will include // Add an unrelated parameter to ensure that tablesort will include
// it in the links that it creates. // it in the links that it creates.
'alpha' => 'beta', 'alpha' => 'beta',
)); );
\Drupal::getContainer()->set('request', $request);
$expected_ts['sort'] = 'desc'; $expected_ts['sort'] = 'desc';
$expected_ts['query'] = array('alpha' => 'beta'); $expected_ts['query'] = array('alpha' => 'beta');
$ts = tablesort_init($headers); $ts = tablesort_init($headers);
...@@ -113,11 +108,9 @@ function testTableSortInit() { ...@@ -113,11 +108,9 @@ function testTableSortInit() {
), ),
); );
// Reset $_GET from previous assertion. // Reset $_GET from previous assertion.
$request = Request::createFromGlobals(); $_GET = array(
$request->query->replace(array(
'order' => '2', 'order' => '2',
)); );
\Drupal::getContainer()->set('request', $request);
$ts = tablesort_init($headers); $ts = tablesort_init($headers);
$expected_ts = array( $expected_ts = array(
'name' => '2', 'name' => '2',
...@@ -130,13 +123,12 @@ function testTableSortInit() { ...@@ -130,13 +123,12 @@ function testTableSortInit() {
// Test complex table headers plus $_GET parameters that should _not_ // Test complex table headers plus $_GET parameters that should _not_
// override the default. // override the default.
$request = Request::createFromGlobals();
$request->query->replace(array( $_GET = array(
// This should not override the table order because this header does not // This should not override the table order because this header does not
// exist. // exist.
'order' => 'bar', 'order' => 'bar',
)); );
\Drupal::getContainer()->set('request', $request);
$ts = tablesort_init($headers); $ts = tablesort_init($headers);
$expected_ts = array( $expected_ts = array(
'name' => '1', 'name' => '1',
...@@ -146,18 +138,18 @@ function testTableSortInit() { ...@@ -146,18 +138,18 @@ function testTableSortInit() {
); );
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => check_plain(var_export($ts, TRUE))))); $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => check_plain(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.'); $this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.');
unset($_GET['sort'], $_GET['order'], $_GET['alpha']);
// Test complex table headers plus $_GET parameters that _should_ // Test complex table headers plus $_GET parameters that _should_
// override the default. // override the default.
$request = Request::createFromGlobals();
$request->query->replace(array( $_GET = array(
'order' => '1', 'order' => '1',
'sort' => 'ASC', 'sort' => 'ASC',
// Add an unrelated parameter to ensure that tablesort will include // Add an unrelated parameter to ensure that tablesort will include
// it in the links that it creates. // it in the links that it creates.
'alpha' => 'beta', 'alpha' => 'beta',
)); );
\Drupal::getContainer()->set('request', $request);
$expected_ts = array( $expected_ts = array(
'name' => '1', 'name' => '1',
'sql' => 'one', 'sql' => 'one',
...@@ -167,5 +159,7 @@ function testTableSortInit() { ...@@ -167,5 +159,7 @@ function testTableSortInit() {
$ts = tablesort_init($headers); $ts = tablesort_init($headers);
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => check_plain(var_export($ts, TRUE))))); $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => check_plain(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.'); $this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.');
unset($_GET['sort'], $_GET['order'], $_GET['alpha']);
} }
} }
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
namespace Drupal\system\Tests\Database; namespace Drupal\system\Tests\Database;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Tests the pager query select extender. * Tests the pager query select extender.
...@@ -136,12 +135,7 @@ function testHavingPagerQuery() { ...@@ -136,12 +135,7 @@ function testHavingPagerQuery() {
* Confirms that every pager gets a valid, non-overlaping element ID. * Confirms that every pager gets a valid, non-overlaping element ID.
*/ */
function testElementNumbers() { function testElementNumbers() {
$_GET['page'] = '3, 2, 1, 0';
$request = Request::createFromGlobals();
$request->query->replace(array(
'page' => '3, 2, 1, 0',
));
\Drupal::getContainer()->set('request', $request);
$name = db_select('test', 't') $name = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
...@@ -174,5 +168,6 @@ function testElementNumbers() { ...@@ -174,5 +168,6 @@ function testElementNumbers() {
->fetchField(); ->fetchField();
$this->assertEqual($name, 'John', 'Pager query #3 with a generated element ID returned the correct results.'); $this->assertEqual($name, 'John', 'Pager query #3 with a generated element ID returned the correct results.');
unset($_GET['page']);
} }
} }
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace Drupal\system\Tests\Entity; namespace Drupal\system\Tests\Entity;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Tests the basic Entity API. * Tests the basic Entity API.
...@@ -349,11 +348,7 @@ function testSort() { ...@@ -349,11 +348,7 @@ function testSort() {
// Test the pager by setting element #1 to page 2 with a page size of 4. // Test the pager by setting element #1 to page 2 with a page size of 4.
// Results will be #8-12 from above. // Results will be #8-12 from above.
$request = Request::createFromGlobals(); $_GET['page'] = '0,2';
$request->query->replace(array(
'page' => '0,2',
));
\Drupal::getContainer()->set('request', $request);
$this->queryResults = $this->factory->get('entity_test_mulrev') $this->queryResults = $this->factory->get('entity_test_mulrev')
->sort("$figures.color") ->sort("$figures.color")
->sort("$greetings.format") ->sort("$greetings.format")
...@@ -380,13 +375,8 @@ protected function testTableSort() { ...@@ -380,13 +375,8 @@ protected function testTableSort() {
// While ordering on bundles do not give us a definite order, we can still // While ordering on bundles do not give us a definite order, we can still
// assert that all entities from one bundle are after the other as the // assert that all entities from one bundle are after the other as the
// order dictates. // order dictates.
$request = Request::createFromGlobals(); $_GET['sort'] = 'asc';
$request->query->replace(array( $_GET['order'] = 'Type';
'sort' => 'asc',
'order' => 'Type',
));
\Drupal::getContainer()->set('request', $request);
$header = array( $header = array(
'id' => array('data' => 'Id', 'specifier' => 'id'), 'id' => array('data' => 'Id', 'specifier' => 'id'),
'type' => array('data' => 'Type', 'specifier' => 'type'), 'type' => array('data' => 'Type', 'specifier' => 'type'),
...@@ -396,12 +386,7 @@ protected function testTableSort() { ...@@ -396,12 +386,7 @@ protected function testTableSort() {
->tableSort($header) ->tableSort($header)
->execute()); ->execute());
$this->assertBundleOrder('asc'); $this->assertBundleOrder('asc');
$_GET['sort'] = 'desc';
$request->query->add(array(
'sort' => 'desc',
));
\Drupal::getContainer()->set('request', $request);
$header = array( $header = array(
'id' => array('data' => 'Id', 'specifier' => 'id'), 'id' => array('data' => 'Id', 'specifier' => 'id'),
'type' => array('data' => 'Type', 'specifier' => 'type'), 'type' => array('data' => 'Type', 'specifier' => 'type'),
...@@ -410,12 +395,8 @@ protected function testTableSort() { ...@@ -410,12 +395,8 @@ protected function testTableSort() {
->tableSort($header) ->tableSort($header)
->execute()); ->execute());
$this->assertBundleOrder('desc'); $this->assertBundleOrder('desc');
// Ordering on ID is definite, however. // Ordering on ID is definite, however.
$request->query->add(array( $_GET['order'] = 'Id';
'order' => 'Id',
));
\Drupal::getContainer()->set('request', $request);
$this->queryResults = $this->factory->get('entity_test_mulrev') $this->queryResults = $this->factory->get('entity_test_mulrev')
->tableSort($header) ->tableSort($header)
->execute(); ->execute();
......
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