Deprecated function addcslashes() warning caused by empty value

Created on 28 November 2022, almost 2 years ago
Updated 4 October 2023, about 1 year ago

Problem/Motivation

There is one query to the Database whose value ends up sent as "null" and Drupal Database connection class throws a warning:

Deprecated function: addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Database\Connection->escapeLike() (line 1525 of core/lib/Drupal/Core/Database/Connection.php).
Drupal\Core\Database\Connection->escapeLike(NULL) (Line: 420)
Drupal\Core\Database\Query\Select->escapeLike(NULL) (Line: 118)
...

Steps to reproduce

Using fivestar module with PHP8.1

Proposed resolution

Check for empty variables with "empty" function or similar instead of boolean "!" operator.

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain dpavon

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

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.71.5 2024