Skip to content

Bugfix/#2378 fix slashes in term mutations#2379

Merged
jasonbahl merged 6 commits intowp-graphql:developfrom
jasonbahl:bugfix/#2378-fix-slashes-in-term-mutations
May 16, 2022
Merged

Bugfix/#2378 fix slashes in term mutations#2379
jasonbahl merged 6 commits intowp-graphql:developfrom
jasonbahl:bugfix/#2378-fix-slashes-in-term-mutations

Conversation

@jasonbahl
Copy link
Copy Markdown
Collaborator

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:

CleanShot 2022-05-16 at 10 11 36

CleanShot 2022-05-16 at 10 12 17

AFTER

Now we can see the slashes are not returned in the response, and the database stores the data as expected:

CleanShot 2022-05-16 at 10 13 26

CleanShot 2022-05-16 at 10 14 04

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

jasonbahl added 3 commits May 16, 2022 10:05
… and descriptions before passing to wp_update_term / wp_insert_term. This matches core WP REST API behavior.
@jasonbahl jasonbahl self-assigned this May 16, 2022
@jasonbahl jasonbahl requested a review from justlevine May 16, 2022 16:15
@coveralls
Copy link
Copy Markdown

coveralls commented May 16, 2022

Coverage Status

Coverage increased (+0.02%) to 79.551% when pulling 6ac1fe6 on jasonbahl:bugfix/#2378-fix-slashes-in-term-mutations into ccaf4e6 on wp-graphql:develop.

@qlty-cloud-legacy
Copy link
Copy Markdown

Code Climate has analyzed commit 6ac1fe6 and detected 0 issues on this pull request.

View more on Code Climate.

@jasonbahl jasonbahl merged commit 5e7f274 into wp-graphql:develop May 16, 2022
@jasonbahl jasonbahl mentioned this pull request May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Term mutations adding extra slashes to names, descriptions, slugs

2 participants