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: querying posts by slug or uri when the post name is non-ascii #2851
fix: querying posts by slug or uri when the post name is non-ascii #2851
Conversation
- update the Post model to return the slug & link passed through urlencode
@@ -527,7 +527,7 @@ protected function init() { | |||
return ! empty( $this->data->ping_status ) ? $this->data->ping_status : null; | |||
}, | |||
'slug' => function () { | |||
return ! empty( $this->data->post_name ) ? $this->data->post_name : null; | |||
return ! empty( $this->data->post_name ) ? urldecode( $this->data->post_name ) : null; |
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.
Avoid too many return
statements within this method.
@@ -683,7 +683,7 @@ protected function init() { | |||
$link = get_permalink( $this->data->ID ); | |||
} | |||
|
|||
return ! empty( $link ) ? $link : null; | |||
return ! empty( $link ) ? urldecode( $link ) : null; |
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.
Avoid too many return
statements within this method.
Code Climate has analyzed commit fa8d9cb and detected 3 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
What does this implement/fix? Explain your changes.
This fixes a bug where querying posts by slug or uri was returning null when the post's name (slug) included non-ascii characters.
Failing Tests: https://github.com/wp-graphql/wp-graphql/actions/runs/5521919716/jobs/10070736088?pr=2851
Passing Tests: https://github.com/wp-graphql/wp-graphql/actions/runs/5522008949/jobs/10070950056?pr=2851
Does this close any currently open issues?
Any other comments?
I've created 2 posts with the following titles:
سلام-دنیا
🍌
This gives me posts visible at the following URLs:
/blog/2023/07/11/🍌/
/blog/2023/07/10/سلام-دنیا/
Before:
Querying these posts by their slugs / uri would return null:
After:
Querying these posts by their slugs / uri returns the expected nodes: