php-kit icon indicating copy to clipboard operation
php-kit copied to clipboard

Prismic::SearchForm url parameters are not correctly separated

Open damyanovg opened this issue 7 years ago • 4 comments

https://github.com/prismicio/php-kit/blob/5670c79a639c09b96ad9460592713fad3a7f777d/src/Prismic/SearchForm.php#L265

Example options: ['pageSize' => 2, 'page' => 2] they are not separated correctly and the reason the response is incorrect.

With '?' as a separator the url looks like this: ...?page=1&pageSize=100&...

Once the question mark is changed to '&' the parameters are correctly separated: ...&page=1&pageSize=100&...

damyanovg avatar Jul 26 '18 12:07 damyanovg

@damyanovg Could you maybe provide me with a little code example of where this problem appeared to you? I am currently trying to go through all the Issues and PRs on this project to attempt to get things back on track.

c0nst4ntin avatar Nov 21 '22 21:11 c0nst4ntin

If you are using the integration fields feature, your api url will typically already contain query parameters such as …/prismic-endpoint?integration-field-stuff=whatever. This lib just appends ?new-query-params to the configured api url without first checking for an existing query - at least it used to. At the least there needs to be a unit test that covers an api url with pre-configured query params.

gsteel avatar Nov 21 '22 22:11 gsteel

I'll Look into this a bit more tomorrow. But that was exactly the problem I was seeing as well

c0nst4ntin avatar Nov 21 '22 22:11 c0nst4ntin

Whilst there seems to be no automated test for this, it appears to be fixed: https://github.com/prismicio-community/php-kit/blob/master/src/Prismic/Utils.php#L10

Should I try to add a test for this? Or should we just close this issue?

c0nst4ntin avatar Nov 24 '22 07:11 c0nst4ntin

I will proceed to mark this as closed for now. If anybody runs into this problem again, please re-open it or start a new issue.

c0nst4ntin avatar Jan 06 '23 16:01 c0nst4ntin