Cannot use query params because of bad syntax "+=" in JwplatformClient::request(). Should be ".="
Hi,
I've been scratching my head around for almost 3 hours trying to figure out how to make use for query params when Listing Media (https://docs.jwplayer.com/platform/reference/get_v2-sites-site-id-media)
Here is the code I was trying out, but that would return false…
$jwplatform_client->Media->list($property, ['page_length' => 2]);
After Xdebugging, I think I finally found that a bad syntax is causing this not to work…
In JwplatformClient::request() line 91 $path += "?" . http_build_query($query_params); should be : $path .= "?" . http_build_query($query_params);
PHP syntax instead of Javascript…
As of now, instead of appending the query params, the $path variable is just converted as an int 0 which breaks the request.
Do you think it could be possible to release a new version with this modified any time soon?
Thank you very much :)
Nicolas
Today I cloned the project's source code in order to create a custom patch but it seems it has already been solved in master dev branch. It seems a version 2.1.1 has been in preparation for a while now... what's blocking its release? Is it safe to use master-dev in production?
In the mean time, here is patch for v 2.0.0
Subject: [PATCH] jwplatform-fix-query-params-bad-js-syntax
---
Index: src/JwplatformClient.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/JwplatformClient.php b/src/JwplatformClient.php
--- a/src/JwplatformClient.php (revision 56bce4c1b5c7b887f83042f589b4b90ca58e0b87)
+++ b/src/JwplatformClient.php (date 1687191653415)
@@ -88,7 +88,7 @@
$body = json_encode($body);
}
if ($query_params !== null) {
- $path += "?" . http_build_query($query_params);
+ $path .= "?" . http_build_query($query_params);
}
return $this->raw_request($method, $path, $body, $headers);