From 27e9202646e9aa720798e50f416d9e83b2af43f6 Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Mon, 27 Mar 2023 16:14:59 +0200 Subject: [PATCH] Fix crash on notification when no geolocation is set --- CHANGELOG.md | 4 ++++ main.sv-geolocation.php | 12 +++++++----- module.sv-geolocation.php | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0a94d8..31b9eac 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.9.1 - 2023-03-27 +### Fixed +- Crash notification param when no geolocation is set. + ## 1.9.0 - 2023-01-31 ### Added - Interactive Google Maps now respect user language. diff --git a/main.sv-geolocation.php b/main.sv-geolocation.php index 6ee22c1..470c1e1 100644 --- a/main.sv-geolocation.php +++ b/main.sv-geolocation.php @@ -145,7 +145,7 @@ function EnumTemplateVerbs() /** * @inheritDoc - * @param ormGeolocation $value + * @param ormGeolocation|null $value * @return string */ function GetForTemplate($value, $sVerb, $oHostObject = null, $bLocalize = true) @@ -154,10 +154,12 @@ function GetForTemplate($value, $sVerb, $oHostObject = null, $bLocalize = true) { case 'rijksdriehoek': case 'rd': - return sprintf('%f,%f', $value->getRijksdriehoekX(), $value->getRijksdriehoekY()); + if ($value instanceof ormGeolocation) return sprintf('%f,%f', $value->getRijksdriehoekX(), $value->getRijksdriehoekY()); + else return; case 'wgs_84': - return (string) $value; + if ($value instanceof ormGeolocation) return sprintf('%f,%f', $value->getLatitude(), $value->getLongitude()); + else return; default: return parent::GetForTemplate($value, $sVerb, $oHostObject, $bLocalize); @@ -368,8 +370,8 @@ public static function getRijksdriehoekReference() * Create ormGeolocation object from string input * * @since 1.8.0 - * @param string $sInput - * @return static + * @param string|null $sInput + * @return static|null */ public static function fromString(?string $sInput) { diff --git a/module.sv-geolocation.php b/module.sv-geolocation.php index e46e0ea..7e13db9 100755 --- a/module.sv-geolocation.php +++ b/module.sv-geolocation.php @@ -5,7 +5,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'sv-geolocation/1.9.0', + 'sv-geolocation/1.9.1', array( // Identification //