PHP deprecation triggered by OpenIDConnectSessionTest

Created on 10 January 2025, about 1 month ago

Problem/Motivation

A PHP deprecation notice is triggered by OpenIdConnectSessionTest::testSaveDestinationUserPath():

1 test triggered 1 PHP deprecation:

1) /var/www/html/modules/contrib/openid_connect/src/OpenIDConnectSession.php:102
ltrim(): Passing null to parameter #1 ($string) of type string is deprecated

Triggered by:

* Drupal\Tests\openid_connect\Unit\OpenIdConnectSessionTest::testSaveDestinationUserPath
  /var/www/html/modules/contrib/openid_connect/tests/src/Unit/OpenIdConnectSessionTest.php:147

Eventually this will cause an error when the module is tested on PHP 9. It's caused by OpenIDConnectSession::saveDestination() trying to build a URL for the user.login route.

Steps to reproduce

See the most recent max PHP version pipeline: https://git.drupalcode.org/project/openid_connect/-/jobs/3855616.

Proposed resolution

The OpenIdConnectSessionTest::testSaveDestination() test gets around this by mocking the route. A quick fix is to do the same mocking in testSaveDestinationUserPath(). But a more appropriate fix might be to check for the existence of the route in saveDestination() or to simply add the User module as a dependency. I'll submit an MR for the quick fix and leave it up to the maintainers to decide whether they want to bother making the code more robust.

πŸ“Œ Task
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dcam

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024