Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297969

Scalar error with \Drupal::request()->query->get()

$
0
0

Problem/Motivation

Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\BadRequestHttpException: "Input value "field_name" contains a non-scalar value." at HttpKernel.php line 83

This error started with Drupal 10, my code worked for years in D8 and D9.

Steps to reproduce

Retrieve an array from the request query

$field_name = \Drupal::request()->query->get('field_name');

the array can be a checkboxes field in a exposed form

Proposed resolution

The workaround I found is to get my array using the all() method, like this:

$field_name = \Drupal::request()->query->all()['field_name']

The API should expect array too, as it did in the past.
But since this seems to be Symfony related, we might not have much to do.
My report could help others that are migrating from D8+ > D10+ tho.


Viewing all articles
Browse latest Browse all 297969

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>