[wp-trac] [WordPress Trac] #43271: Issue with term duplicate check in wp_insert_term
WordPress Trac
noreply at wordpress.org
Thu Aug 9 01:39:25 UTC 2018
#43271: Issue with term duplicate check in wp_insert_term
-----------------------------------------+------------------------------
Reporter: strategio | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 4.9.4
Severity: normal | Resolution:
Keywords: has-patch reporter-feedback | Focuses:
-----------------------------------------+------------------------------
Changes (by boonebgorges):
* keywords: => has-patch reporter-feedback
Comment:
Hi @strategio - Thanks very much for your clear description of the issue.
The check you've cited was introduced in [30238] as part of a schema
change in `wp_terms`. You can read the gory details in the commit message
and the linked ticket. Long story short, it will be difficult to simply
remove the check. For the same reason, it may not be advisable to switch
over to `get_term_by()`, because that function interacts with the cache in
a way that might introduce the kinds of data-integrity problems that the
direct database-query is meant to avoid.
A specific filter is here should be doable. See [attachment:"43271.diff"].
Does this look reasonable to you? Note that the use of this filter will
put WPML on the hook for guarding against the kinds of replication-related
data-integrity issues that [30238] was meant to guard against.
> The above data validation is only performed in wp_insert_term and not
in wp_update_term which makes the data validation inconsistent between the
two function. This also allowed us to demonstrate that two terms with the
same slug can live together in the same taxonomy.
By this, I assume you mean that you are using a filter on the return value
of `get_term_by()` or `wp_unique_term_slug()` here
https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-
includes/taxonomy.php#L2734, and by "*can* live together" you mean "our
plugin triggers duplicate slugs within a taxonomy and WP continues to
work" - correct? Or, alternatively, do you mean that it's possible, using
`wp_update_term()` *alone* (with no filters), to update a term so that it
shares a slug with a sibling from the same taxonomy? The latter would be a
problem. The former seems OK, and if I understand correctly, then
[attachment:"43271.diff"] will let you do the same thing in the case of
`wp_insert_term()` :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43271#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list