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.
Issue fork anonymous_login-3503476
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:
- 3503476-query-string
changes, plain diff MR !28
- 3503476-the-query-parameters
changes, plain diff MR !17
Comments
Comment #3
zewebmaster commentedComment #6
anton4uk commentedThanks, @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.
Comment #8
anton4uk commented