From 0332a154c0a029eb8a451c46be8dc64d3bc5f3ba Mon Sep 17 00:00:00 2001 From: Steve Powell Date: Tue, 12 Jan 2021 18:15:37 -0600 Subject: [PATCH] Update GeoIP2.php Better error message to share what was in $address, instead of just assuming it was a street address. if using a proxy like CloudFlare, the $address may be a comma delimited list of addresses and both executeQuery AND geocodeQuery will fail. Suggest just grabbing the first address and moving on ....something like $address = explode(',', $address)[0]; --- src/Provider/GeoIP2/GeoIP2.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Provider/GeoIP2/GeoIP2.php b/src/Provider/GeoIP2/GeoIP2.php index 3171f8f29..f188dc2a3 100644 --- a/src/Provider/GeoIP2/GeoIP2.php +++ b/src/Provider/GeoIP2/GeoIP2.php @@ -47,9 +47,10 @@ public function __construct(GeoIP2Adapter $adapter) public function geocodeQuery(GeocodeQuery $query): Collection { $address = $query->getText(); + $address = explode(',', $address)[0]; $locale = $query->getLocale() ?: 'en'; // Default to English if (!filter_var($address, FILTER_VALIDATE_IP)) { - throw new UnsupportedOperation('The GeoIP2 provider does not support street addresses, only IP addresses.'); + throw new UnsupportedOperation(sprintf('"%s" must be called with an IP addresses. Got "%s" instead.', __METHOD__, $address)); } if ('127.0.0.1' === $address) { @@ -110,6 +111,7 @@ public function getName(): string */ private function executeQuery(string $address): string { + $address = explode(',', $address)[0]; $uri = sprintf('file://geoip?%s', $address); try {