Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(sdk-php): keep a query string already in a raw request path
Yudhi Armyndharisdd5b90e7bfda
diff --git a/sdk/php/src/Http/HttpExecutor.php b/sdk/php/src/Http/HttpExecutor.phpindex 03f68f68b..0dcf12615 100644--- a/sdk/php/src/Http/HttpExecutor.php+++ b/sdk/php/src/Http/HttpExecutor.php@@ -158,17 +158,19 @@ class HttpExecutor'Accept' => 'application/json',]),];- // Build query string, skipping null values (so absent optionals aren't sent).+ // Build query string, skipping null values (so absent optionals aren't sent). Guzzle's+ // 'query' option would replace a query already in a raw path, so extend the URL instead.+ $url = $this->baseUrl . $path;$query = array_filter($query, fn ($v) => $v !== null);if ($query !== []) {- $options['query'] = $query;+ $url .= (str_contains($path, '?') ? '&' : '?') . http_build_query($query, '', '&', PHP_QUERY_RFC3986);}if ($body !== null) {$options['json'] = $body;}try {- $response = $this->http->request($method, $this->baseUrl . $path, $options);+ $response = $this->http->request($method, $url, $options);} catch (ConnectException $e) {// cURL error 28 (CURLE_OPERATION_TIMEDOUT) is the canonical timeout// signal, surfaced via the handler context. We check errno firstdiff --git a/sdk/php/tests/HttpExecutorTest.php b/sdk/php/tests/HttpExecutorTest.phpindex b74a0ef47..2f3d203cd 100644--- a/sdk/php/tests/HttpExecutorTest.php+++ b/sdk/php/tests/HttpExecutorTest.php@@ -26,4 +26,17 @@ class HttpExecutorTest extends TestCase}$this->assertSame([], $backend->calls());}++ public function testQueryParamsExtendAQueryAlreadyInThePath(): void+ {+ $backend = (new MockBackend())->on(200, [])->on(200, []);+ $client = $backend->makeClient();++ $client->request('GET', '/api/anything?a=1', ['b' => 2, 'skip' => null]);+ $this->assertSame('/api/anything', $backend->lastCall()['path']);+ $this->assertSame('a=1&b=2', $backend->lastCall()['query']);++ $client->request('GET', '/api/anything', ['q' => 'a b']);+ $this->assertSame('q=a%20b', $backend->lastCall()['query']);+ }}