WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#27966 closed defect (bug) (duplicate)

wp_insert_term checking term with slug only without taxonomy

Reported by: aalakkad Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:

Description

When the function wp_insert_term is called, it uses term_exists function to check for already existing terms.

The problem is the term_exists function is called with 1 parameter (the slug parameter) without the taxonomy parameter.

To emulate the problem, create 2 custom taxonomy, add a term to the first one, then add a new term to the second one with the same name and slug; then try editing one and the changes will be made on the other one too.

You can find the line (in wp-includes/taxonomy.php) https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/taxonomy.php#L2430.

To fix it just add the second parameter (taxonomy) to the term_exists function.

Change History (2)

#1 @aalakkad
7 years ago

To fix it, change line 2430 in (wp-includes/taxonomy.php) to:

        if ( $term_id = term_exists($slug, $taxonomy) ) {

#2 @helen
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

There's more to this whole shared terms thing than that - see a proposed roadmap here: http://make.wordpress.org/core/2013/07/28/potential-roadmap-for-taxonomy-meta-and-post-relationships/

Closing this as a duplicate of #5809.

Note: See TracTickets for help on using tickets.