[wp-trac] [WordPress Trac] #43271: Issue with term duplicate check in wp_insert_term
WordPress Trac
noreply at wordpress.org
Mon Aug 13 17:30:17 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.1
Severity: normal | Resolution:
Keywords: has-patch reporter-feedback | Focuses:
-----------------------------------------+------------------------------
Comment (by strategio):
@boonebgorges, I understand how you defined the parameters now, and indeed
it makes sense.
However, `$duplicate_term` has just 2 properties: `term_id` and
`term_taxonomy_id`.
See the query => `$duplicate_term = $wpdb->get_row( $wpdb->prepare(
"SELECT t.term_id, tt.term_taxonomy_id FROM ...`
So you will have to adjust it to:
{{{
$duplicate_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.term_id,
tt.term_taxonomy_id, t.slug FROM $wpdb->terms t INNER JOIN
$wpdb->term_taxonomy tt ON ( tt.term_id = t.term_id ) WHERE t.slug = %s
AND tt.parent = %d AND tt.taxonomy = %s AND t.term_id < %d AND
tt.term_taxonomy_id != %d", $slug, $parent, $taxonomy, $term_id, $tt_id )
);
}}}
I am not sure it's necessary to add more properties for now, but I need
the `slug` one to avoid an extra query.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43271#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list