Commit 052a50ca authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4423 (Don't crash on non-numeric latitude/longitude values)

parent 79dff83d
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -120,10 +120,31 @@ function _autofill_geo_cpfs($row)
    // Address from GPS (or IP)
    if (!$has_city || !$has_county || !$has_state || !$has_country) {
        if ($has_gps) {
            $latitude = $row['field_' . strval($latitude_field)];
            $longitude = $row['field_' . strval($longitude_field)];

            $_latitude = mixed();
            $_latitude = $row['field_' . strval($latitude_field)];
            if (is_float($_latitude)) {
                $latitude = $_latitude;
            } elseif ((is_string($_latitude)) && (is_numeric($_latitude))) {
                $latitude = floatval($_latitude);
            } else {
                $latitude = null;
            }

            $_longitude = mixed();
            $_longitude = $row['field_' . strval($longitude_field)];
            if (is_float($_longitude)) {
                $longitude = $_longitude;
            } elseif ((is_string($_longitude)) && (is_numeric($_longitude))) {
                $longitude = floatval($_longitude);
            } else {
                $longitude = null;
            }

            if (($latitude !== null) && ($longitude !== null)) {
                $address_parts = reverse_geocode($latitude, $longitude);
            } else {
                $address_parts = null;
            }
            if (!is_null($address_parts)) {
                list(, , $city, $county, $state, , $country) = $address_parts;
                if (($city_field !== null) && (!$has_city) && (!empty($city))) {