PHP8.1: Deprecated function: trim()

Created on 27 July 2023, 11 months ago
Updated 18 December 2023, 6 months ago

Problem/Motivation

Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in SolrBaseQuery->normalizeParamValue() (line 548 of /apachesolr/Solr_Base_Query.php).

Proposed resolution

According to note php.net there is a behavior change in php 8.

You used to be able to say:
$p1 = trim($_POST['p1']);
This will now throw deprecated warnings if parameter p1 is not set. It is better to say:
$p1 = trim($_POST['p1']??'');
or
$p1 = isset($_POST['p1']) ? trim($_POST['p1']) : null;
or
$p1 = isset($_POST['p1']) ? trim($_POST['p1']) : '';

isset($value) ? trim($value) : ''; - use both PHP "classic" and "strict" type handling where applicable. PHP 7.0 assertions and PHP 8.1 deprecation messages can support here well.

🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

🇺🇦Ukraine Igumnov_aleksey

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

Production build 0.69.0 2024