Bugfix/#2378 fix slashes in term mutations#2379
Merged
jasonbahl merged 6 commits intowp-graphql:developfrom May 16, 2022
Merged
Bugfix/#2378 fix slashes in term mutations#2379jasonbahl merged 6 commits intowp-graphql:developfrom
jasonbahl merged 6 commits intowp-graphql:developfrom
Conversation
… and descriptions before passing to wp_update_term / wp_insert_term. This matches core WP REST API behavior.
|
Code Climate has analyzed commit 6ac1fe6 and detected 0 issues on this pull request. View more on Code Climate. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this implement/fix? Explain your changes.
This fixes a bug where creating or updating terms with a WPGraphQL Mutation would save slashes in the database if the term had an apostrophe.
For example "What's up" would become "What's up" in the database and "What\'s up" when being returned in the response.
Does this close any currently open issues?
Closes #2378
Any relevant logs, error output, GraphiQL screenshots, etc?
BEFORE
We can see that a mutation that includes apostrophes in the name and description leads to slashes being output in the response, and a slash stored raw in the database:
AFTER
Now we can see the slashes are not returned in the response, and the database stores the data as expected:
Any other comments?
This now more closely matches the behavior of the WP REST API: https://github.com/WordPress/WordPress/blob/aeb3b7530af57db885dfa8f377a7c6aa22e309bd/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php#L613
And core edit-tags.php page: https://github.com/WordPress/WordPress/blob/master/wp-admin/edit-tags.php#L183