-
Notifications
You must be signed in to change notification settings - Fork 216
Fix Products by Category JSON response error #2551
Conversation
|
Size Change: 0 B Total Size: 1.99 MB ℹ️ View Unchanged
|
bd6f981 to
e0c1a2a
Compare
nerrad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! In this case passing 10 is unneeded because unlike the equivalent JavaScript function (parseInt) php does default to 10 for the base here.
Also there's a php linting fail that is being reported by Travis.
Pre-approving so you can merge after the fix!
|
@Aljullu If this is never set to -1 for any reason we could/should use |
|
@mikejolley the reason that we opted for our own wrapping method instead of Looking at the code, I can't spot any obvious place were But even if -1 is not currently used in our codebase, does it make sense to restrict it? What are the downsides of using our own methods for validation? |
yes it most certainly does make sense to restrict to valid values. The terms API uses 0 for unlimited results rather than -1, and I recall making all endpoints follow this rather than allowing for -1 values. The min is also set to 0 in the validation schema. |
|
Sorry Albert, I should have thought to look at the schema, I agree with Mike here, the schema for the API has 0 as the minimum value so it looks like |
|
Makes sense, thanks for the input @mikejolley @nerrad. I will push a PR fixing this today. 👍 |
I'm not sure what are the exact steps to reproduce this issue, I found it in a random test site I have but everything was working fine in all others. After adding the Products by Category block, the list of categories doesn't appear and instead it shows an error (

The response is not a valid JSON response.):Inspecting the JSON response, it's like this:
After this PR, everything works fine again:

Tagging this as
blockerbecause I was unable to reproduce it in 2.5.15, so it must be a regression in 2.6.How to test the changes in this Pull Request: