Page 1 of 1

sdk4php urlencode missing

PostPosted:Tue Jul 12, 2022 8:55 am
by lbilke
Hello, I've been writing a script that relies on searching for custom property groups using the PHP SDK. I realized that this is impossible due to a missing urlencode() in openKM/src/openkm/impl/SearchImpl.php. The the property encoding in makeUri() should be changed like this:
Code: Select all
@@ -922,7 +922,7 @@
       }
     }
     foreach ($queryParams->getProperties() as $key => $value) {
-      $uri .= '&property=' . $key . '=' . urlencode($value);
+      $uri .= '&property=' . urlencode($key) . '=' . urlencode($value);
     }
     if ($queryParams->getAuthor() != '') {
       $uri .= '&author=' . urlencode($queryParams->getAuthor());
Without the urlencode function around $key, it is impossible to search for properties such as okp:consulting.name, as the colon is not encoded.
What is also unclear is the fact that when you get a saved query using the API, it is impossible to use this query because the properties are in a completely different format. Instead of being in a simple array they are contained in an "Entry" object that is completely incompatible with the makeUri() function of SearchImpl.php

I hope I am not misunderstanding anything but passing the properties to the QueryParams object as a simple array and adding urlencode($key) solved my problems.

Re: sdk4php urlencode missing

PostPosted:Wed Aug 24, 2022 3:47 pm
by sochoa
Hello, thanks for the observation, what you indicated has just been corrected.

You can review the included improvements here https://docs.openkm.com/kcenter/view/sd ... on-1x.html.
You could also download the new version SDK4PHP-1.21 here https://docs.openkm.com/kcenter/view/sdk4php/

Thank you for your collaboration.