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
fix: taking care about the case of empty order by #3063
Conversation
Thanks so much for this commit, @mohjak 🙌 Can you provide an example of something that currently triggers this error - both for review purposes and to help us write the necessary unit tests? (For example, I see that |
(tests are failing because this is based on |
You are welcome @justlevine, I have updated the pull request info. Please let me know if there are anything still missing. |
@justlevine We are not enforcing string type, but we're trying to resolve if there is no value in in the old code: return "{$orderby}, {$key} {$order}"; So, If the |
Yes understood. Since the latter two methods don't enforce a param type, those concatenations could produce a fatal error if they're not being type guarded upstream to make sure they're only getting a string. Was just giving an example of something that having a test case helps us scope when reviewing. The updated PR description looks like it now has the info we need 👌 |
@mohjak I was able to reproduce the issue you were seeing where Before merging, we'll need a test case that ensures this fix doesn't have a future regression. I'm working on writing a test case now. |
…(fails in v1.22.0, passes with PR wp-graphql#3063)
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.
Approving. I added a test here: mohjak#1
And will merge that test in a follow-up PR.
What does this implement/fix? Explain your changes.
This fix resolves the issue when the 'ORDER BY' is missing in cursor pagination.
Does this close any currently open issues?
Any relevant logs, error output, GraphiQL screenshots, etc?
Reproduce Link
I have installed WPGraphQL Version 1.21.0 in addition to this version of an offset pagination plugin https://github.com/alaa-alshamy/wp-graphql-offset-pagination/releases/tag/v0.2.0.2.
I have the following categories for example as parent, child
When I run the following GraphQL query to count total of children of the targeted parent that id is
38
.Then the total is returning
null
as you can see in the image below:After Applying the fix of this pull request the issue resolves:
Any other comments?
I believe the following testing environment should help you to reproduce the issue, this is hosted in local by flywheel:
https://probable-tendency.localsite.io/wp-admin/admin.php?page=graphiql-ide
Basic Authentication:
Username: pattern
Password: unusual
Admin Panel:
Username: admin
Password: password
Where has this been tested?
Operating System: …
Ubuntu 22.04.4 LTS
WordPress Version: …
6.4.3