Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for empty $addressPart can fail #15

Closed
rintisch opened this issue Dec 10, 2021 · 1 comment · Fixed by #16
Closed

Check for empty $addressPart can fail #15

rintisch opened this issue Dec 10, 2021 · 1 comment · Fixed by #16

Comments

@rintisch
Copy link
Contributor

Is neither city nor zip is entered the check if (empty($addressPart)) fails because a white space makes $addressPart being not empty.

foreach ([$street, $zip . ' ' . $city, $country] as $addressPart) {
if (empty($addressPart)) {
continue;
}
$addressParts[] = trim($addressPart);
}
$address = ltrim(implode(',', $addressParts), ',');

Would be a solution to check with strlen(trim($addressPart)) <= 0 instead.

Background:
Otherwise this can lead to two consecutive commas. As a result the request leads sometimes to ZERO_RESULTS.

Is the solution okay? Shall I make a PR?

@bmack
Copy link
Member

bmack commented Dec 10, 2021

Yes. Please go ahead.

rintisch added a commit to rintisch/geocoding that referenced this issue Dec 17, 2021
Not given zip and city will no longer be added
as empty string to the google API request. This
could lead to two consecutive commas.
As a result the request leads sometimes
to `ZERO_RESULTS`.

Closes b13#15.
@bmack bmack closed this as completed in #16 Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants