Problem/Motivation

Passing NULL to trim() is not allowed anymore in PHP 8.1. The code even explicitly checks for NULL (and not just an empty string), but only after the trim(.

Steps to reproduce

Proposed resolution

I'm moving the checks up to the intial if and just making it a general not-empty check, because an empty value also doesn't need to be trimmed. That would currently even result in an invalid value.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Berdir’s picture

Note: Accessing this as $item->lat/lng is IMHO preferred and faster (this creates a typed data object only to then just access the value again. $item->lat is optimized to not do that.

ChristianAdamski’s picture

Status: Needs review » Postponed (maintainer needs more info)

Latitude / Longitude can be "0". Somewhere off Ghana in the Atlantic Ocean.

Opinion?

Berdir’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
718 bytes

fair enough :)

How about we use the existing isEmpty() method of the item, that already explicitly checks for null and ''.

Berdir’s picture

Berdir’s picture

Hm, various test fails on recent mariadb/mysql versions. "interesting", but I guess not directly related to this. There is one more similar problem with a preg_match. a trivial fix would be to just cast the input to string. it's similar to this case, where the code first parses $this->getValue() and only afterwards checks if there actually is a value.. so maybe another early return instead could make sense?

ChristianAdamski’s picture

Status: Needs review » Needs work

preg_match: have to look at it

Geometry fails: dear God have mercy. All the geometry functions work slightly differently MySQL5, MySQL8, MariaDB, PGSQL

  • Berdir authored 6798062 on 8.x-3.x
    Issue #3277114 by Berdir: PHP8.1: Deprecated function: trim(): Passing...
ChristianAdamski’s picture

  • ChristianAdamski authored f035be5 on 8.x-3.x
    Issue #3277114 by ChristianAdamski: PHP8.1: Deprecated function: trim...
ChristianAdamski’s picture

Status: Needs review » Fixed

Thanks!

Geometry in a separate issue

Status: Fixed » Closed (fixed)

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