]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Cast lat/lon to float; check for non-empty
authorEvan Prodromou <evan@e14n.com>
Sun, 9 Jun 2013 01:16:58 +0000 (21:16 -0400)
committerEvan Prodromou <evan@e14n.com>
Sun, 9 Jun 2013 01:16:58 +0000 (21:16 -0400)
lib/activityobject.php

index b26fc87e24bc5fe0179b822a801689806d1f95e0..5a42a1dfb3431b847fd1804df9666efdeb699fde 100644 (file)
@@ -906,25 +906,27 @@ class ActivityObject
 
                 list($lat, $lon) = explode(' ', $this->geopoint);
 
-                $object['location'] = array(
-                    'objectType' => 'place',
-                    'position' => sprintf("%+02.5F%+03.5F/", $lat, $lon),
-                    'lat' => $lat,
-                    'lon' => $lon
-                );
+                if (!empty($lat) && !empty($lon)) {
+                    $object['location'] = array(
+                        'objectType' => 'place',
+                        'position' => sprintf("%+02.5F%+03.5F/", $lat, $lon),
+                        'lat' => $lat,
+                        'lon' => $lon
+                    );
 
-                $loc = Location::fromLatLon($lat, $lon);
+                    $loc = Location::fromLatLon((float)$lat, (float)$lon);
 
-                if ($loc) {
-                    $name = $loc->getName();
+                    if ($loc) {
+                        $name = $loc->getName();
 
-                    if ($name) {
-                        $object['location']['displayName'] = $name;
-                    }
-                    $url = $loc->getURL();
+                        if ($name) {
+                            $object['location']['displayName'] = $name;
+                        }
+                        $url = $loc->getURL();
 
-                    if ($url) {
-                        $object['location']['url'] = $url;
+                        if ($url) {
+                            $object['location']['url'] = $url;
+                        }
                     }
                 }
             }