diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php index 600a6dbd7163bf8d81cd2e05b3e9955a99be1ef2..4f6acbf9664f8992239bfeb61bb77be374f3edd4 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php @@ -128,7 +128,7 @@ public function processAttachments(AttachmentsInterface $response) { * An array of commands ready to be returned as JSON. */ protected function buildAttachmentsCommands(AjaxResponse $response, Request $request) { - $ajax_page_state = $request->request->get('ajax_page_state'); + $ajax_page_state = $request->request->all('ajax_page_state'); // Aggregate CSS/JS if necessary, but only during normal site operation. $optimize_css = !defined('MAINTENANCE_MODE') && $this->config->get('css.preprocess'); diff --git a/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php b/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php index a48664468db9be8fb2a6ffd6ce72b441a01fd4a1..d9e5d67983d75ef575254e488e42fd3c6b6fc038 100644 --- a/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php +++ b/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php @@ -31,7 +31,7 @@ public function getContext($query_arg = NULL) { return ($value !== NULL) ? $value : ''; } elseif ($this->requestStack->getCurrentRequest()->query->has($query_arg)) { - $value = $this->requestStack->getCurrentRequest()->query->get($query_arg); + $value = $this->requestStack->getCurrentRequest()->query->all()[$query_arg]; if (is_array($value)) { return http_build_query($value); } diff --git a/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php b/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php index e9dd1ed17539fc4f323a9e7857bf849c3295e7b0..3438d0fd27c792e66b7d2d4a94b65adcf477ad77 100644 --- a/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php @@ -61,7 +61,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch $title = $main_content['#title'] ?? $this->titleResolver->getTitle($request, $route_match->getRouteObject()); // Determine the dialog options and the target for the OpenDialogCommand. - $options = $request->request->get('dialogOptions', []); + $options = $request->request->all('dialogOptions'); $target = $this->determineTargetSelector($options, $route_match); $response->addCommand(new OpenDialogCommand($target, $title, $content, $options)); diff --git a/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php b/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php index d903acf88d15c4e8f8d273cc87ae01ed581972d2..df80b7dce00ccc5237f8264a09b452ce86587900 100644 --- a/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php @@ -31,7 +31,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // Determine the title: use the title provided by the main content if any, // otherwise get it from the routing information. - $options = $request->request->get('dialogOptions', []); + $options = $request->request->all('dialogOptions'); $response->addCommand(new OpenModalDialogCommand($title, $content, $options)); return $response; diff --git a/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php b/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php index 6c598ccb0a915703ff39ce9b2bc9fec05eee3fad..02a1b232930635f348e658b1770195d4d1341f69 100644 --- a/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php @@ -64,7 +64,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // Determine the title: use the title provided by the main content if any, // otherwise get it from the routing information. - $options = $request->request->get('dialogOptions', []); + $options = $request->request->all('dialogOptions'); $response->addCommand(new OpenOffCanvasDialogCommand($title, $content, $options, NULL, $this->position)); return $response; } diff --git a/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php b/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php index 5cd2ee305797c48727a8309ccc24fc97746d20a4..1c19472df868a68b67811d19060e1cab8ee13f6c 100644 --- a/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php +++ b/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php @@ -65,7 +65,7 @@ public function __construct(CsrfTokenGenerator $token_generator, ConfigFactoryIn * {@inheritdoc} */ public function applies(RouteMatchInterface $route_match) { - $ajax_page_state = $this->requestStack->getCurrentRequest()->request->get('ajax_page_state'); + $ajax_page_state = $this->requestStack->getCurrentRequest()->request->all('ajax_page_state'); return !empty($ajax_page_state['theme']) && isset($ajax_page_state['theme_token']); } @@ -73,7 +73,7 @@ public function applies(RouteMatchInterface $route_match) { * {@inheritdoc} */ public function determineActiveTheme(RouteMatchInterface $route_match) { - $ajax_page_state = $this->requestStack->getCurrentRequest()->request->get('ajax_page_state'); + $ajax_page_state = $this->requestStack->getCurrentRequest()->request->all('ajax_page_state'); $theme = $ajax_page_state['theme']; $token = $ajax_page_state['theme_token']; diff --git a/core/modules/comment/src/Controller/CommentController.php b/core/modules/comment/src/Controller/CommentController.php index 2cba4ac918df84b83351010d536b203a8f1586c8..9304e20009e15352651a06256d62982798033104 100644 --- a/core/modules/comment/src/Controller/CommentController.php +++ b/core/modules/comment/src/Controller/CommentController.php @@ -337,11 +337,12 @@ public function renderNewCommentsNodeLinks(Request $request) { throw new AccessDeniedHttpException(); } - $nids = $request->request->get('node_ids'); - $field_name = $request->request->get('field_name'); - if (!isset($nids)) { + if (!$request->request->has('node_ids') || !$request->request->has('field_name')) { throw new NotFoundHttpException(); } + $nids = $request->request->all('node_ids'); + $field_name = $request->request->get('field_name'); + // Only handle up to 100 nodes. $nids = array_slice($nids, 0, 100); diff --git a/core/modules/contextual/src/ContextualController.php b/core/modules/contextual/src/ContextualController.php index cd6ddb40a85830148a75f7d46320d1a1228f0d19..378b5236c4b5eafda1bc9596de12cc91eec53053 100644 --- a/core/modules/contextual/src/ContextualController.php +++ b/core/modules/contextual/src/ContextualController.php @@ -60,15 +60,15 @@ public static function create(ContainerInterface $container) { * @see contextual_preprocess() */ public function render(Request $request) { - $ids = $request->request->get('ids'); - if (!isset($ids)) { + if (!$request->request->has('ids')) { throw new BadRequestHttpException('No contextual ids specified.'); } + $ids = $request->request->all('ids'); - $tokens = $request->request->get('tokens'); - if (!isset($tokens)) { + if (!$request->request->has('tokens')) { throw new BadRequestHttpException('No contextual ID tokens specified.'); } + $tokens = $request->request->all('tokens'); $rendered = []; foreach ($ids as $key => $id) { diff --git a/core/modules/field_ui/src/Form/FieldConfigEditForm.php b/core/modules/field_ui/src/Form/FieldConfigEditForm.php index a0fa3d3f4cba16802c87d7cf9c8f8928d1f3be81..f2346e70697c8ce8dbd226f8d73c30a5ffb1f921 100644 --- a/core/modules/field_ui/src/Form/FieldConfigEditForm.php +++ b/core/modules/field_ui/src/Form/FieldConfigEditForm.php @@ -207,7 +207,7 @@ public function save(array $form, FormStateInterface $form_state) { $this->messenger()->addStatus($this->t('Saved %label configuration.', ['%label' => $this->entity->getLabel()])); $request = $this->getRequest(); - if (($destinations = $request->query->get('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) { + if (($destinations = $request->query->all('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) { $request->query->remove('destinations'); $form_state->setRedirectUrl($next_destination); } diff --git a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php index d70c0aadd4cb7aa019cf729cec8cac418ed3fbc7..d6dec922019a10b978f91a69f3a37e458a3ff7f7 100644 --- a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php @@ -229,7 +229,7 @@ public function save(array $form, FormStateInterface $form_state) { $this->entity->save(); $this->messenger()->addStatus($this->t('Updated field %label field settings.', ['%label' => $field_label])); $request = $this->getRequest(); - if (($destinations = $request->query->get('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) { + if (($destinations = $request->query->all('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) { $request->query->remove('destinations'); $form_state->setRedirectUrl($next_destination); } diff --git a/core/modules/history/src/Controller/HistoryController.php b/core/modules/history/src/Controller/HistoryController.php index c6a48349038767cd46e675e9752490b52c5b67aa..ca3498ead8a72424b749a690a155ed0ae2986489 100644 --- a/core/modules/history/src/Controller/HistoryController.php +++ b/core/modules/history/src/Controller/HistoryController.php @@ -28,10 +28,10 @@ public function getNodeReadTimestamps(Request $request) { throw new AccessDeniedHttpException(); } - $nids = $request->request->get('node_ids'); - if (!isset($nids)) { + if (!$request->request->has('node_ids')) { throw new NotFoundHttpException(); } + $nids = $request->request->all('node_ids'); return new JsonResponse(history_read_multiple($nids)); } diff --git a/core/modules/jsonapi/src/Controller/EntityResource.php b/core/modules/jsonapi/src/Controller/EntityResource.php index 9ce8a725ce2dfd82cccea6f3d27f84e986af54e1..541fbd06795aab42a1ca34dfeb4f626e9bd705c5 100644 --- a/core/modules/jsonapi/src/Controller/EntityResource.php +++ b/core/modules/jsonapi/src/Controller/EntityResource.php @@ -1235,13 +1235,13 @@ protected function entityExists(EntityInterface $entity) { */ protected function getJsonApiParams(Request $request, ResourceType $resource_type) { if ($request->query->has('filter')) { - $params[Filter::KEY_NAME] = Filter::createFromQueryParameter($request->query->get('filter'), $resource_type, $this->fieldResolver); + $params[Filter::KEY_NAME] = Filter::createFromQueryParameter($request->query->all('filter'), $resource_type, $this->fieldResolver); } if ($request->query->has('sort')) { - $params[Sort::KEY_NAME] = Sort::createFromQueryParameter($request->query->get('sort')); + $params[Sort::KEY_NAME] = Sort::createFromQueryParameter($request->query->all()['sort']); } if ($request->query->has('page')) { - $params[OffsetPage::KEY_NAME] = OffsetPage::createFromQueryParameter($request->query->get('page')); + $params[OffsetPage::KEY_NAME] = OffsetPage::createFromQueryParameter($request->query->all('page')); } else { $params[OffsetPage::KEY_NAME] = OffsetPage::createFromQueryParameter(['page' => ['offset' => OffsetPage::DEFAULT_OFFSET, 'limit' => OffsetPage::SIZE_MAX]]); diff --git a/core/modules/jsonapi/src/EventSubscriber/ResourceResponseSubscriber.php b/core/modules/jsonapi/src/EventSubscriber/ResourceResponseSubscriber.php index 6d47e9d2343735ddfb8798da56a619e8a08cacc4..742a57598a8bf7718f76cc3d7d4759268f94f3db 100644 --- a/core/modules/jsonapi/src/EventSubscriber/ResourceResponseSubscriber.php +++ b/core/modules/jsonapi/src/EventSubscriber/ResourceResponseSubscriber.php @@ -146,10 +146,10 @@ protected static function generateContext(Request $request) { 'account' => NULL, 'sparse_fieldset' => NULL, ]; - if ($request->query->get('fields')) { + if ($request->query->has('fields')) { $context['sparse_fieldset'] = array_map(function ($item) { return explode(',', $item); - }, $request->query->get('fields')); + }, $request->query->all('fields')); } return $context; } diff --git a/core/modules/jsonapi/tests/src/Kernel/Controller/EntityResourceTest.php b/core/modules/jsonapi/tests/src/Kernel/Controller/EntityResourceTest.php index 859cb805997af378e23a92218750091b3a1d9336..1d43897ca91245e6ed7f57cbae9e101d5143cabc 100644 --- a/core/modules/jsonapi/tests/src/Kernel/Controller/EntityResourceTest.php +++ b/core/modules/jsonapi/tests/src/Kernel/Controller/EntityResourceTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\jsonapi\Kernel\Controller; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Http\InputBag; use Drupal\jsonapi\CacheableResourceResponse; use Drupal\jsonapi\ResourceType\ResourceType; use Drupal\jsonapi\JsonApiResource\Data; @@ -13,7 +14,6 @@ use Drupal\user\Entity\Role; use Drupal\user\Entity\User; use Drupal\user\RoleInterface; -use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; /** @@ -187,7 +187,7 @@ protected function createEntityResource() { */ public function testGetPagedCollection() { $request = Request::create('/jsonapi/node/article'); - $request->query = new ParameterBag([ + $request->query = new InputBag([ 'sort' => 'nid', 'page' => [ 'offset' => 1, @@ -216,7 +216,7 @@ public function testGetPagedCollection() { */ public function testGetEmptyCollection() { $request = Request::create('/jsonapi/node/article'); - $request->query = new ParameterBag(['filter' => ['id' => 'invalid']]); + $request->query = new InputBag(['filter' => ['id' => 'invalid']]); // Get the response. $resource_type = new ResourceType('node', 'article', NULL); diff --git a/core/modules/menu_ui/src/Controller/MenuController.php b/core/modules/menu_ui/src/Controller/MenuController.php index 7958c101ace4cdb212876becccc8a3b327b0fb71..e76ff6c5605e676b8faa79345a5f7de791866c50 100644 --- a/core/modules/menu_ui/src/Controller/MenuController.php +++ b/core/modules/menu_ui/src/Controller/MenuController.php @@ -50,7 +50,7 @@ public static function create(ContainerInterface $container) { */ public function getParentOptions(Request $request) { $available_menus = []; - if ($menus = $request->request->get('menus')) { + if ($menus = $request->request->all('menus')) { foreach ($menus as $menu) { $available_menus[$menu] = $menu; } diff --git a/core/modules/quickedit/src/QuickEditController.php b/core/modules/quickedit/src/QuickEditController.php index 6a2a794ea2afb95ecb5376bc84074438e8c7bbc6..57982d8949ca2a7a089ec3688db12ebfd4290286 100644 --- a/core/modules/quickedit/src/QuickEditController.php +++ b/core/modules/quickedit/src/QuickEditController.php @@ -118,11 +118,11 @@ public static function create(ContainerInterface $container) { * The JSON response. */ public function metadata(Request $request) { - $fields = $request->request->get('fields'); - if (!isset($fields)) { + if (!$request->request->has('fields')) { throw new NotFoundHttpException(); } - $entities = $request->request->get('entities'); + $fields = $request->request->all('fields'); + $entities = $request->request->all('entities'); $metadata = []; foreach ($fields as $field) { @@ -196,10 +196,10 @@ private static function checkCsrf(Request $request, AccountInterface $account) { */ public function attachments(Request $request) { $response = new AjaxResponse(); - $editors = $request->request->get('editors'); - if (!isset($editors)) { + if (!$request->request->has('editors')) { throw new NotFoundHttpException(); } + $editors = $request->request->all('editors'); $response->setAttachments($this->editorSelector->getEditorAttachments($editors)); @@ -257,7 +257,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view // Re-render the updated field for other view modes (i.e. for other // instances of the same logical field on the user's page). - $other_view_mode_ids = $request->request->get('other_view_modes') ?: []; + $other_view_mode_ids = $request->request->all('other_view_modes'); $other_view_modes = array_map($render_field_in_view_mode, array_combine($other_view_mode_ids, $other_view_mode_ids)); $response->addCommand(new FieldFormSavedCommand($output, $other_view_modes)); diff --git a/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php b/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php index 88f304e2bdde826d034e0bfc7e2dca397fa3b7b9..1efc2570d087ce44a7f08ae772d244d7221602e1 100644 --- a/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php +++ b/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php @@ -60,7 +60,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // Determine the title: use the title provided by the main content if any, // otherwise get it from the routing information. - $options = $request->request->get('dialogOptions', []); + $options = $request->request->all('dialogOptions'); // Override width option. switch ($this->mode) { case 'wide': diff --git a/core/tests/Drupal/Tests/Core/Theme/AjaxBasePageNegotiatorTest.php b/core/tests/Drupal/Tests/Core/Theme/AjaxBasePageNegotiatorTest.php index 3f7f4f41417a68dcda3ef2e124ed6d5fc2e294ff..5a51c0944173fddbc7abd2aaba9796e958a7ba40 100644 --- a/core/tests/Drupal/Tests/Core/Theme/AjaxBasePageNegotiatorTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/AjaxBasePageNegotiatorTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\Core\Theme; use Drupal\Core\Access\CsrfTokenGenerator; +use Drupal\Core\Http\InputBag; use Drupal\Core\Routing\RouteMatch; use Drupal\Core\Theme\AjaxBasePageNegotiator; use Drupal\Tests\UnitTestCase; @@ -55,6 +56,7 @@ protected function setUp(): void { */ public function testApplies($request_data, $expected) { $request = new Request([], $request_data); + $request->request = new InputBag($request->request->all()); $route_match = RouteMatch::createFromRequest($request); $this->requestStack->push($request); @@ -79,6 +81,7 @@ public function testDetermineActiveThemeValidToken() { $theme_token = 'valid_theme_token'; $request = new Request([], ['ajax_page_state' => ['theme' => $theme, 'theme_token' => $theme_token]]); + $request->request = new InputBag($request->request->all()); $this->requestStack->push($request); $route_match = RouteMatch::createFromRequest($request); @@ -96,6 +99,7 @@ public function testDetermineActiveThemeInvalidToken() { $theme_token = 'invalid_theme_token'; $request = new Request([], ['ajax_page_state' => ['theme' => $theme, 'theme_token' => $theme_token]]); + $request->request = new InputBag($request->request->all()); $this->requestStack->push($request); $route_match = RouteMatch::createFromRequest($request); @@ -115,6 +119,7 @@ public function testDetermineActiveThemeDefaultTheme() { $theme_token = ''; $request = new Request([], ['ajax_page_state' => ['theme' => $theme, 'theme_token' => $theme_token]]); + $request->request = new InputBag($request->request->all()); $this->requestStack->push($request); $route_match = RouteMatch::createFromRequest($request);