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

CommentFileSizeAuthor
#4 reroll-diff-462-1538.txt14.16 KBspokje

Issue fork drupal-3254250

Command icon 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:

Comments

longwave created an issue. See original summary.

Spokje made their first commit to this issue’s fork.

spokje’s picture

StatusFileSize
new14.16 KB

MR!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.

spokje’s picture

Status: Active » Needs review
longwave’s picture

Thanks! 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.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

No 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?

spokje’s picture

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?

FWIW: I am in favour of backporting the deprecations to 9.4.x.

catch’s picture

This 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.

catch’s picture

Status: Reviewed & tested by the community » Needs review
catch’s picture

Status: Needs review » Needs work

Since there's been discussion/iterations on that issue, let's remove the hunks here, probably the way to get both in quickest overall.

spokje’s picture

Status: Needs work » Postponed
catch’s picture

Status: Postponed » Needs review
daffie’s picture

Status: Needs review » Needs work

A couple of minor points to be fixed.

spokje’s picture

Status: Needs work » Needs review
  • Addressed threads opened by @daffie (tips hat for the review)
  • Merged latest commit on 10.0.x-dev
daffie’s picture

Status: Needs review » Reviewed & tested by the community

All code changes look good to me.
For me it is RTBC.

longwave’s picture

  • catch committed 4ca93c9 on 10.0.x
    Issue #3254250 by Spokje, longwave, catch, daffie: [Symfony 6]...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Test failure looks unrelated.

Committed 4ca93c9 and pushed to 10.0.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.