From: Michael J. Rubinsky Date: Fri, 18 Dec 2009 05:08:08 +0000 (-0500) Subject: Don't write a record for geolocation data if we don't have any and X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6014a39d021b0fc86ccbb3e1e83cb616153e7422;p=horde.git Don't write a record for geolocation data if we don't have any and delete the record if one exists but we have no geolocation data. --- diff --git a/kronolith/lib/Geo/Mysql.php b/kronolith/lib/Geo/Mysql.php index 5104bb95e..839e55aac 100644 --- a/kronolith/lib/Geo/Mysql.php +++ b/kronolith/lib/Geo/Mysql.php @@ -30,6 +30,15 @@ class Kronolith_Geo_Mysql extends Kronolith_Geo_Sql if ($count instanceof PEAR_Error) { throw new Horde_Exception($count->getMessage()); } + + /* Do we actually have data? */ + if (!$point && $count) { + // Delete the record. + $sql = "DELETE FROM kronolith_events_geo WHERE event_id = '" . $event_id . "'"; + } elseif (!$point) { + return; + } + /* INSERT or UPDATE */ if ($count) { $sql = "UPDATE kronolith_events_geo SET event_coordinates = GeomFromText('POINT(" . $point['lat'] . " " . $point['lon'] . ")') WHERE event_id = '" . $event_id . "'"; diff --git a/kronolith/lib/Geo/Sql.php b/kronolith/lib/Geo/Sql.php index 844417ea1..e6432935f 100644 --- a/kronolith/lib/Geo/Sql.php +++ b/kronolith/lib/Geo/Sql.php @@ -117,6 +117,14 @@ class Kronolith_Geo_Sql extends Kronolith_Geo throw new Horde_Exception($count->getMessage()); } + /* Do we actually have data? */ + if (!$point && $count) { + // Delete the record. + $sql = "DELETE FROM kronolith_events_geo WHERE event_id = '" . $event_id . "'"; + } elseif (!$point) { + return; + } + /* INSERT or UPDATE */ $params = array($point['lat'], $point['lng'], $event_id); if ($count) {