geocoder-php / geocoder-php/Geocoder
Bug when use chain and GeoIp2 at first position with cache
未关闭
还没有人认领这个 Issue。
question
- 主要语言
- PHP
- 星标
- 4k
- 派生
- 525
- 平均合并
- 8 分钟
- 30 天内合并 PR
- 1
描述
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();
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 GeoIp2 provider 的 executeQuery 和 geocodeQuery 方法开始,然后跟踪 Chain::geocodeQuery 如何处理来自第一个 provider 的空 collection,以及如何为后续 provider 读取 cache。复现一个将 GeoIp2 放在首位、将自定义 provider 放在第二位的 chain;当 GeoIp2 的空响应不再阻止使用后续 provider,并且预期的错误行为已得到验证时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100