Bug Description
GeoService::getApiCallResult() is intended to retry the Google Maps Geocoding API call when an OVER_QUERY_LIMIT response is received but the retry condition is inverted causing the method to recurse on successful (OK) responses which is the exact opposite of the intended behaviour.
Steps to Reproduce
Configure maxRetries to any value greater than 0 (e.g. 10, which is already the default) in the extension configuration and trigger a geocoding request. Even when the API responds successfully with status OK, the method will recurse maxRetries additional times, resulting in maxRetries + 1 total API calls (e.g. 11 calls instead of 1).
Root Cause
Condition in getApiCallResult():
if (($result['status'] ?? '') === 'OVER_QUERY_LIMIT' || $remainingTries <= 0) {
return $result;
}
return $this->getApiCallResult($url, $remainingTries - 1);
This returns early when OVER_QUERY_LIMIT is received and recurses when status is OK. The operator should be !==, not ===.
Proposed Fix
Change === to !==:
- if (($result['status'] ?? '') === 'OVER_QUERY_LIMIT' || $remainingTries <= 0) {
+ if (($result['status'] ?? '') !== 'OVER_QUERY_LIMIT' || $remainingTries <= 0) {
return $result;
}
return $this->getApiCallResult($url, $remainingTries - 1);
With this fix the method returns immediately on a successful OK response and only retries when OVER_QUERY_LIMIT is returned and retries remain.
Bug Description
GeoService::getApiCallResult()is intended to retry the Google Maps Geocoding API call when anOVER_QUERY_LIMITresponse is received but the retry condition is inverted causing the method to recurse on successful (OK) responses which is the exact opposite of the intended behaviour.Steps to Reproduce
Configure
maxRetriesto any value greater than0(e.g.10, which is already the default) in the extension configuration and trigger a geocoding request. Even when the API responds successfully with statusOK, the method will recursemaxRetriesadditional times, resulting inmaxRetries + 1total API calls (e.g. 11 calls instead of 1).Root Cause
Condition in
getApiCallResult():This returns early when
OVER_QUERY_LIMITis received and recurses when status isOK. The operator should be!==, not===.Proposed Fix
Change
===to!==:With this fix the method returns immediately on a successful
OKresponse and only retries whenOVER_QUERY_LIMITis returned and retries remain.