$request->get may no longer return array as of Symfony 6.0

Created on 8 January 2023, over 1 year ago
Updated 31 August 2023, 10 months ago

Problem/Motivation

Expected a scalar value as a 2nd argument to \"Symfony\\Component\\HttpFoundation\\InputBag::get()\", \"array\" given.

This issue only appears in d10, since in symfony 6 the InputBag::get() no longer accepts arrays as default values,

Steps to reproduce

use defaults for an api endpoint

Proposed resolution

diff --git a/modules/jsonapi_defaults/src/Controller/EntityResource.php b/modules/jsonapi_defaults/src/Controller/EntityResource.php
index 7a2d14c..34ae566 100644
--- a/modules/jsonapi_defaults/src/Controller/EntityResource.php
+++ b/modules/jsonapi_defaults/src/Controller/EntityResource.php
@@ -74,7 +74,7 @@ class EntityResource extends JsonApiEntityResourse {
 
     $filters = array_merge(
       $default_filter,
-      $request->query->get('filter', [])
+      $request->query->all()['filter'] ?? []
     );
 
     $sort = [];

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇩🇪Germany woldtwerk Stralibu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024