Skip to content

Drupal does not like how repeated query parameters are handled #1946

@berenddeboer

Description

@berenddeboer

I'm having an issue a litte bit like #1691, but for query parameters.. Use case is CloudFront + function urls. This is the request that is sent:

POST https://example.com/media-library?
  media_library_opener_id=media_library.opener.editor&
  media_library_allowed_types%5B0%5D=image&
  media_library_selected_type=image&
  media_library_remaining=1&
  media_library_opener_parameters%5Bfilter_format_id%5D=basic_html&
  hash=Y0GzprGKj6n2Vs7_sMumYICU-hNpfhtmFiOnEdVJnuY&
  _wrapper_format=drupal_modal&
  ajax_form=1&
  _wrapper_format=drupal_ajax

So duplicated _wrapper_format (appears twice).

This causes this crash:

Symfony\Component\HttpFoundation\Exception\BadRequestException:
Input value "_wrapper_format" contains a non-scalar value. 
in Symfony\Component\HttpFoundation\InputBag->get() 
(line 38 of /var/task/vendor/symfony/http-foundation/InputBag.php).

Not sure how to fix this: it seems bref currently turns repetitions into an array. But Drupal (Symfony perhaps) doesn't like that at all. My solution is to pick the last value, so I've a hard-coded list like:

if (isset($_GET['op']) && is_array($_GET['op'])) {
  $_GET['op'] = end($_GET['op']);          // keep the last value
}
if (isset($_GET['_wrapper_format']) && is_array($_GET['_wrapper_format'])) {
  $_GET['_wrapper_format'] = end($_GET['_wrapper_format']);          // keep the last value
}

Then Drupal/Symfony is happy. Am I right it is bref turning repeated query parameters into an array? And can that either be turned off, or changed to simply pick the lastvalue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions