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.

Issue fork geofield-3378136

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pfrenssen created an issue. See original summary.

pfrenssen’s picture

Issue tags: +PHP 8.1

pfrenssen’s picture

Status: Active » Needs review
didebru’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed +RTBC from my point of view.

itamair made their first commit to this issue’s fork.

  • itamair committed 75279e2d on 8.x-1.x authored by pfrenssen
    Issue #3378136: Deprecation warning: passing null to trim() in...
itamair’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @pfrenssen, nice catch ... committed into dev, already part of new release 8.x-1.54

pfrenssen’s picture

Wow thanks for the quick reaction!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.