Jump to content

Webservice library curl request


jonask

Recommended Posts

hey there,

I came across a pretty strange bug with the webservice library and curl and wonder if that has happened to anyone else here before or if anyone has a reasonable explanation.

I developed a module that uses the webservice to gather product data. On several test systems everything worked fine.
When deployed to the productive system, the webservice stopped delivering results when the request included a filter.

After several hours of debugging I was able to trace the bug into the webservice library: when using a filter in the webservice call, the url which is used in the curl request is as follows:
shop.xy/api/products?filter[name]=%[e]%&display=full => empty xml

If we open that URL within a browser or use the webservice library on our productive system we get an empty xml sheet as result. It works fine on the test system.
To solve the problem and get the requested data we simply have to replace the "&" in the URL with "&" but only if that is in front of the display parameter.
shop.xy/api/products?filter[name]=%[e]%&display=full => correct data
 
If we replace every occurence of "&", for example when we have added the "limit" Parameter (shop.xy/api/products?filter[name]=%[e]%&display=full&limit=5 => empty xml) then the script again stops working.


The solution: Adding the following line into line 109 makes everything work as it should.
$url = str_replace("&display", "&display", $url);

 

   
We have included the library into our module which means that the presta system itself is still updateable, but still this is just a workaround and against developing standards. Are there any recommendations or explanations for this kind of behaviour?

Productive system is running php 7.0.27 with curl 7.38.0. We used the most up-to-date version of the library and I'll attach my new version of it.

 

Thank you!

 

PSWebServiceLibrary.php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...