Problem/Motivation

When using this module with Drupal core 9.3.0-rc1 and PHP 8.1, the following deprecation notice appears on every page:

Deprecated function: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->onKernelRequestCheckRedirect() (line 125 of modules/contrib/redirect/src/EventSubscriber/RedirectRequestSubscriber.php).

Issue fork redirect-3252259

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

DieterHolvoet created an issue. See original summary.

dieterholvoet’s picture

Status: Active » Needs review
mondrake’s picture

Issue tags: +PHP 8.1
alexpott’s picture

Status: Needs review » Needs work

This is one of the simplest fixes so probably okay. I wonder why we are not doing $request_query = $request->query->all(); - however both Symfony's query parameter bag and parse_str() can result in changing the initial query string.

Hmmm - actually given that \Symfony\Component\HttpFoundation\Request::getQueryString() calls \Symfony\Component\HttpFoundation\Request::normalizeQueryString() I think we should take the opportunity to change this to $request_query = $request->query->all(); as that is guaranteed to return an array and then we don't have to parse the query params multiple times.

berdir’s picture

There used to be some really nasty bugs around caching and redirect loops where a normalized query string was different but caching uses the other one. But, I think that was actually all in \Drupal\redirect\EventSubscriber\RouteNormalizerRequestSubscriber::onKernelRequestRedirect(), this here is just old code, hasn't changed since 2014. So yes, sounds fine to do that.

dieterholvoet’s picture

Status: Needs work » Needs review
kim.pepper’s picture

Status: Needs review » Reviewed & tested by the community

Simple change. Looks good.

  • Berdir committed e29b7f7 on 8.x-1.x authored by DieterHolvoet
    Issue #3252259 by DieterHolvoet: Deprecated function: parse_str():...
berdir’s picture

Thanks, merged.

berdir’s picture

Status: Reviewed & tested by the community » Fixed
berdir’s picture

There's one more 8.1 related test problem that people following this might be interested in fixing (see what I did there?): #3253718: Fix PHP 8.1 test fails

Status: Fixed » Closed (fixed)

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