Changeset 30238
- Timestamp:
- 11/05/2014 12:59:51 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r30210 r30238 2903 2903 $tt_id = (int) $wpdb->insert_id; 2904 2904 2905 /* 2906 * Sanity check: if we just created a term with the same parent + taxonomy + slug but a higher term_id than 2907 * an existing term, then we have unwittingly created a duplicate term. Delete the dupe, and use the term_id 2908 * and term_taxonomy_id of the older term instead. Then return out of the function so that the "create" hooks 2909 * are not fired. 2910 */ 2911 $duplicate_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.term_id, tt.term_taxonomy_id 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 ) ); 2912 if ( $duplicate_term ) { 2913 $wpdb->delete( $wpdb->terms, array( 'term_id' => $term_id ) ); 2914 $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) ); 2915 2916 $term_id = (int) $duplicate_term->term_id; 2917 $tt_id = (int) $duplicate_term->term_taxonomy_id; 2918 2919 clean_term_cache( $term_id, $taxonomy ); 2920 return array( 'term_id' => $term_id, 'term_taxonomy_id' => $tt_id ); 2921 } 2922 2905 2923 /** 2906 2924 * Fires immediately after a new term is created, before the term cache is cleaned.
Note: See TracChangeset
for help on using the changeset viewer.