Problem/Motivation

In certain circumstances, such as login via an SSO, or a new session at each connection, it can happen that query processing - carried out in the AnonymousLoginSubscriber - throws up an error message.

Deprecated function: str_replace(): Passing null to parameter #3 (closed) ($subject) of type array|string is deprecated in Drupal\anonymous_login\EventSubscriber\AnonymousLoginSubscriber->redirect() (line 241 of modules/contrib/anonymous_login/src/EventSubscriber/AnonymousLoginSubscriber.php).

Proposed resolution

This is because the $request->query->count() method returns a count() on the array of parameters, which are not necessarily consistent with the value of $this->server->get('QUERY_STRING') returned by the $request->getQueryString() method.

What's missing is simply a test on the value of $request->getQueryString(), - a method whose return value can be null.

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

zewebmaster created an issue. See original summary.

zewebmaster’s picture

Status: Active » Needs review

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

anton4uk’s picture

Thanks, @zewebmaster. The query parameters can differ from the query string when other code adds parameters to the request, so the redirect now checks only the query string. Besides the deprecation, the destination also got an empty ? in this case.
Added unit tests.

  • anton4uk committed a847e0b0 on 8.x-2.x
    Issue #3503476: Use the query string when passing the query along
    
anton4uk’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.