WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/09/2015 03:58:35 AM (6 years ago)
Author:
dd32
Message:

In wp_update_term(), limit duplicate slug checks to the same taxonomy as the updated term.

In 4.1 [30240], wp_insert_term() was modified to allow the creation of terms
with duplicate slugs, as long as the terms are in different taxonomies.
wp_update_term() didn't get the corresponding modification, with the result
that term updates fail when the term being updated shares a slug with an older
term, regardless of that older term's taxonomy.

Props ipm-frommen.
Merges [30985] to the 4.1 branch.
Fixes #30780.

Location:
branches/4.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1

  • branches/4.1/src/wp-includes/taxonomy.php

    r31084 r31378  
    33543354
    33553355    // Check for duplicate slug
    3356     $id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) );
    3357     if ( $id && ($id != $term_id) ) {
     3356    $duplicate = get_term_by( 'slug', $slug, $taxonomy );
     3357    if ( $duplicate && $duplicate->term_id != $term_id ) {
    33583358        // If an empty slug was passed or the parent changed, reset the slug to something unique.
    33593359        // Otherwise, bail.
Note: See TracChangeset for help on using the changeset viewer.