When trying to geocode from file KML handler emits a warning containing the whole file

Created on 20 February 2023, over 1 year ago

Problem/Motivation

A normal configuration for 'geocode from file' is to enable GPX, KML, GeoJSON... providers. This module passes the providers and attempts to geocode with each in turn in a try/catch https://git.drupalcode.org/project/geocoder/-/blob/8.x-3.x/src/Geocoder....

The KML module specifically emits a warning on line https://github.com/itamair/geoPHP/blob/master/lib/adapters/KML.class.php... when it attempts to read a non XML file.

Warning: Attempt to read property "nodeName" on null in KML->geomFromXML() (line 94 of /app/vendor/itamair/geophp/lib/adapters/KML.class.php).

KML->geomFromXML() (Line: 66)
KML->geomFromText('{
"type": "featurecollection",
....

Problematic, but worse this warning continues to include the whole file. Which can be huge. So even if not rendered it's a memory suck.

Steps to reproduce

Configure a geofield to be geocoded from a file. Enable geocoders including KML. Don't have KML as the last. Upload another format.

Proposed resolution

It would probably be more efficient already to call https://github.com/itamair/geoPHP/blob/master/geoPHP.inc#L228 before starting to attempt to read the files.

Remaining tasks

Agree approach. Make MR.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands ekes

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

Comments & Activities

Production build 0.69.0 2024