Deprecation warning: passing null to trim() in GeofieldProximityArgument::getParsedReferenceLocation()

Created on 31 July 2023, over 1 year ago

Problem/Motivation

I am getting the following deprecation warning on PHP 8.1:

Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\geofield\Plugin\views\argument\GeofieldProximityArgument->getParsedReferenceLocation() (line 209 of modules/contrib/geofield/src/Plugin/views/argument/GeofieldProximityArgument.php).

We are using the return value of \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getValue() and passing it to trim() without checking if it is a NULL value. Passing null values to trim() is deprecated in PHP 8.1.

Proposed resolution

Check if the value is NULL, or directly cast it to a string before trimming.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇧🇬Bulgaria pfrenssen Sofia

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