Bug when use chain and GeoIp2 at first position with cache
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the GeoIp2 provider's executeQuery and geocodeQuery methods, then trace how Chain::geocodeQuery handles an empty collection from the first provider and cache reads for later providers. Reproduce a chain with GeoIp2 first and a custom provider second; done means an empty GeoIp2 response no longer prevents the later provider from being used, with the intended error behavior verified.
Written by the indexing model from the issue text.
Description
GeoIp2 return empty collection and save it in cache after that next providers(custom) load from cache empty collection instead of using his code
$result = json_decode($this->executeQuery($address));
if (null === $result) {
return new AddressCollection([]);
}
$result = json_decode(''); //NULL
private function executeQuery(string $address): string
{
$uri = sprintf('file://geoip?%s', $address);
try {
$result = $this->adapter->getContent($uri);
} catch (AddressNotFoundException $e) {
return '';
} catch (AuthenticationException $e) {
throw new InvalidCredentials(
$e->getMessage(),
$e->getCode(),
$e
);
} catch (OutOfQueriesException $e) {
throw new QuotaExceeded(
$e->getMessage(),
$e->getCode(),
$e
);
}
return $result;
}
I think there should not be return '';, but there should be fatal
public function geocodeQuery(GeocodeQuery $query): Collection
{
foreach ($this->providers as $provider) {
try {
$result = $provider->geocodeQuery($query);
if (!$result->isEmpty()) {
return $result;
}
} catch (\Throwable $e) {
$this->log(
'alert',
sprintf('Provider "%s" could geocode address: "%s".', $provider->getName(), $query->getText()),
['exception' => $e]
);
}
}
return new AddressCollection();
}
\Geocoder\Provider\Chain\Chain::geocodeQuery now always return empty collectioon \Geocoder\Model\AddressCollection();
- Dominant language
- PHP
- Stars
- 4k
- Forks
- 525
- Avg merge
- 8m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from geocoder-php/Geocoder
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
geocoder-php/Geocoder#1272 ·
-
question
Difficulty 4/5 3-5 days Newbie friendliness 25/100
geocoder-php/Geocoder#1267 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
geocoder-php/Geocoder#1266 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 38/100
geocoder-php/Geocoder#1244 · 2 comments · 2 reactions ·
-
provider
Difficulty 4/5 3-5 days Newbie friendliness 30/100
geocoder-php/Geocoder#1243 ·
All issues in geocoder-php/Geocoder
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
a11y admissions.uiowa.edu needs grooming SiteImprove best practice
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Save States Menu Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
pluginsGLPI/datainjection#673 ·