PHP 8.1 deprecation explode(): Passing null to parameter #2

Created on 12 January 2023, over 1 year ago
Updated 12 January 2024, 6 months ago

Problem/Motivation

In a Drupal 9.5.0 with Advanced Varnish 4.0.7 running on the PHP 8.1, we are seeing this deprecation message:

Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\adv_varnish\CacheManager->getCacheSettings() (line 446 of /my_drupal_path/web/modules/contrib/adv_varnish/src/CacheManager.php)

Steps to reproduce

The error seems to be triggered when users are authenticating to Drupal and cache control header is not set I believe.
I am not able to reproduce this in my local, but seen these errors in production.

Proposed resolution

Implemented logic to check if parameter #2 is not empty before calling explode() function.
Patch is attached below.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mihaic

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024