diff --git a/LibreNMS/Util/Dns.php b/LibreNMS/Util/Dns.php index 4879049e73..be6f9057b3 100644 --- a/LibreNMS/Util/Dns.php +++ b/LibreNMS/Util/Dns.php @@ -57,8 +57,8 @@ class Dns implements Geocoder { foreach ($this->getRecord($hostname, 'LOC') as $record) { return [ - 'lat' => $record->latitude, - 'lng' => $record->longitude, + 'lat' => $record->latitude ?? null, + 'lng' => $record->longitude ?? null, ]; } diff --git a/tests/Unit/LocationTest.php b/tests/Unit/LocationTest.php index c468998ee5..3dd402da0b 100644 --- a/tests/Unit/LocationTest.php +++ b/tests/Unit/LocationTest.php @@ -60,6 +60,7 @@ class LocationTest extends TestCase public function testCanSetEncodedLocation() { + Config::set('geoloc.dns', false); $device = Device::factory()->make(); /** @var Device $device */ // valid coords @@ -92,6 +93,7 @@ class LocationTest extends TestCase public function testCanHandleGivenCoordinates() { + Config::set('geoloc.dns', false); $device = Device::factory()->make(); /** @var Device $device */ $location = Location::factory()->withCoordinates()->make(); @@ -136,6 +138,7 @@ class LocationTest extends TestCase public function testCanSetDnsCoordinate() { + Config::set('geoloc.dns', true); $device = Device::factory()->make(); /** @var Device $device */ $location = Location::factory()->withCoordinates()->make();