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

Cannot use query params because of bad syntax "+=" in JwplatformClient::request(). Should be ".=" #41

Open
Nicolas-Bouteille opened this issue May 25, 2023 · 2 comments

Comments

@Nicolas-Bouteille
Copy link

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

@Nicolas-Bouteille
Copy link
Author

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?

@Nicolas-Bouteille
Copy link
Author

Nicolas-Bouteille commented Jun 19, 2023

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);

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

No branches or pull requests

1 participant