Problem/Motivation
When upgrading to Symfony 5.4 various tests throw deprecation warnings:
Since symfony/http-foundation 5.1: Passing a non-scalar value as 2nd argument to "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated, pass a scalar or null instead.
Since symfony/http-foundation 5.1: Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated, and will throw a "Symfony\Component\HttpFoundation\Exception\BadRequestException" exception in Symfony 6.0, use "Symfony\Component\HttpFoundation\InputBag::all($key)" instead.
In #3162016: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated we first approached this problem but then the first solution was rolled back, a simpler solution was implemented, but the remainder of the changes were not committed in that issue.
Steps to reproduce
Proposed resolution
Reuse code from #3162016: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated that was not committed.
Use $request->query->all(...)
when retrieving an array.
Use $request->query->get(...)
when retrieving a scalar.
Use $request->query->all()[...]
when retrieving either an array or scalar and the subsequent code can handle both types.
Where the query isn't guaranteed to be set, start using $request->query->has()
.
User interface changes
no
API changes
no
Data model changes
no
Release notes snippet
no
Comment | File | Size | Author |
---|---|---|---|
#4 | reroll-diff-462-1538.txt | 14.16 KB | Spokje |
Issue fork drupal-3254250
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3254250-symfony-6-retrieving changes, plain diff MR !1538
Comments
Comment #4
SpokjeMR!1538 is basically a reroll from MR!462 from #3162016: [Symfony 6] Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated.
Reroll diff between those MRs attached.
Comment #5
SpokjeComment #6
longwaveThanks! Testing this over in #3197482-34: Update Drupal 10 to depend on Symfony 5.4 (as a stepping stone to Symfony 6, for deprecation checking support), if that passes with no InputBag deprecations then this is OK to go.
Comment #7
longwaveNo InputBag related fails in the linked issue, so this is ready to go into 10.0.x.
One question though: should we backport the deprecations to our custom InputBag and effectively trigger the same deprecations in 9.4.x? We have InputBag in 9.4.x and we can give contrib etc a chance to upgrade before 10.0.x, if the deprecations are actually triggered there?
Comment #8
SpokjeFWIW: I am in favour of backporting the deprecations to 9.4.x.
Comment #9
catchThis is covering some of the same ground as #3248454: [Symfony6] The Drupal\Tests\media_library\Kernel\MediaLibraryStateTest fails for Symfony 5.4, we should either mark that issue as duplicate, or remove the hunks added here that are duplicated there.
Comment #10
catchComment #11
catchSince there's been discussion/iterations on that issue, let's remove the hunks here, probably the way to get both in quickest overall.
Comment #12
SpokjeDe-hunked (eat that auto-correct!) the MR
Postponing on #3248454: [Symfony6] The Drupal\Tests\media_library\Kernel\MediaLibraryStateTest fails for Symfony 5.4
Comment #13
catchComment #14
daffie CreditAttribution: daffie commentedA couple of minor points to be fixed.
Comment #15
Spokje10.0.x-dev
Comment #16
daffie CreditAttribution: daffie commentedAll code changes look good to me.
For me it is RTBC.
Comment #17
longwaveRTBC+1, applying this MR solved all InputBag deprecations over in #3197482: Update Drupal 10 to depend on Symfony 5.4 (as a stepping stone to Symfony 6, for deprecation checking support)
Comment #19
catchTest failure looks unrelated.
Committed 4ca93c9 and pushed to 10.0.x. Thanks!