Skip to content

Commit 0109a68

Browse files
authored
[Nominatim] Set optional parameters of http_build_query (#1131)
If arg_separator is not set, the default value comes from arg_separator.output which is not always set to the value we need here, which is '&'. On Ubuntu the default is '&'. There is no need to adhere to any system defaults here because we know exactly in which context the URLs we build are used: for a backend request that is executed soon in the same PHP handler. The same parameters are used in the MapQuest provider.
1 parent f2afa22 commit 0109a68

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Provider/Nominatim/Nominatim.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function geocodeQuery(GeocodeQuery $query): Collection
9898
'addressdetails' => 1,
9999
'extratags' => 1,
100100
'limit' => $query->getLimit(),
101-
]);
101+
], '', '&', PHP_QUERY_RFC3986);
102102

103103
$countrycodes = $query->getData('countrycodes');
104104
if (!is_null($countrycodes)) {
@@ -107,25 +107,25 @@ public function geocodeQuery(GeocodeQuery $query): Collection
107107

108108
$url .= '&'.http_build_query([
109109
'countrycodes' => implode(',', $countrycodes),
110-
]);
110+
], '', '&', PHP_QUERY_RFC3986);
111111
} else {
112112
$url .= '&'.http_build_query([
113113
'countrycodes' => strtolower($countrycodes),
114-
]);
114+
], '', '&', PHP_QUERY_RFC3986);
115115
}
116116
}
117117

118118
$viewbox = $query->getData('viewbox');
119119
if (!is_null($viewbox) && is_array($viewbox) && 4 === count($viewbox)) {
120120
$url .= '&'.http_build_query([
121121
'viewbox' => implode(',', $viewbox),
122-
]);
122+
], '', '&', PHP_QUERY_RFC3986);
123123

124124
$bounded = $query->getData('bounded');
125125
if (!is_null($bounded) && true === $bounded) {
126126
$url .= '&'.http_build_query([
127127
'bounded' => 1,
128-
]);
128+
], '', '&', PHP_QUERY_RFC3986);
129129
}
130130
}
131131

@@ -165,7 +165,7 @@ public function reverseQuery(ReverseQuery $query): Collection
165165
'lon' => $longitude,
166166
'addressdetails' => 1,
167167
'zoom' => $query->getData('zoom', 18),
168-
]);
168+
], '', '&', PHP_QUERY_RFC3986);
169169

170170
$content = $this->executeQuery($url, $query->getLocale());
171171

@@ -278,7 +278,7 @@ private function executeQuery(string $url, string $locale = null): string
278278
if (null !== $locale) {
279279
$url .= '&'.http_build_query([
280280
'accept-language' => $locale,
281-
]);
281+
], '', '&', PHP_QUERY_RFC3986);
282282
}
283283

284284
$request = $this->getRequest($url);

0 commit comments

Comments
 (0)