TypeError: Cannot assign null to property Drupal\geofield\Plugin\Field\FieldType\GeofieldItem::$geometry

Created on 20 June 2024, 5 months ago
Updated 4 July 2024, 4 months ago

Problem/Motivation

In the project this type error is appearing in several processes:

In ProcessBase.php line 171:
 
  Unable to decode output into JSON: Syntax error
 
  TypeError: Cannot assign null to property Drupal\geofield\Plugin\Field\FieldType\GeofieldItem::$geometry of type G
  eometry in Drupal\geofield\Plugin\Field\FieldType\GeofieldItem->isEmpty() (line 206 of /var/www/web/modul
  es/contrib/geofield/src/Plugin/Field/FieldType/GeofieldItem.php).
has context menu

The problem occurs in this line of code. WHen the geometry is being loaded, it may return null, but the geometry property is not nullable so in case of returning NULL it will throw the error.

Steps to reproduce

Upgrade to 1.58. Run the method isEmpty over a geofield that has value but it returns null when it is being loaded.

Proposed resolution

Make the geometry property nullable, and check it is instance of Geometry class before calling isEmpty method.

🐛 Bug report
Status

Fixed

Version

1.58

Component

Code

Created by

🇪🇸Spain omarlopesino

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024