PHP 8.1 strtolower() compatibility

Created on 7 July 2023, over 1 year ago
Updated 6 December 2023, 12 months ago

Problem/Motivation

When running my site on PHP 8.1, I get the following error:

Deprecated function: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in dmemcache_serialize_extension() (line 736 of /home/example/public_html/sites/all/modules/memcache/dmemcache.inc).

Steps to reproduce

All I did was to update my PHP version to 8.1.

Proposed resolution

The problematic code is in dmemcache.inc in the function dmemcache_serialize_extension().

$preferred = strtolower(variable_get('memcache_serialize', NULL));

The fix is to add a null coalescing operator which converts any NULL values into an empty string.

$preferred = strtolower(variable_get('memcache_serialize', NULL) ?? '');

*** Marking this as Major since it's a potential blocker for some sites which display errors.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States hargobind Austin, Texas

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024