[wp-trac] [WordPress Trac] #30780: Inconsistent behavior/results of wp_insert_term and wp_update_term

WordPress Trac noreply at wordpress.org
Sun Dec 21 18:26:02 UTC 2014


#30780: Inconsistent behavior/results of wp_insert_term and wp_update_term
-----------------------------------+--------------------
 Reporter:  ipm-frommen            |       Owner:
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  4.1.1
Component:  Taxonomy               |     Version:  4.1
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+--------------------
Changes (by boonebgorges):

 * keywords:  has-patch => has-patch 2nd-opinion
 * milestone:  4.2 => 4.1.1


Comment:

 dubh - Thanks for the report. This is indeed a related issue. I'm moving
 this ticket into the 4.1.1 milestone, because the behavior you describe
 sounds like a regression in 4.1.

 A summary of what's happening: As of 4.1, multiple terms can be created
 with the same slug, as long as they're not in the same taxonomy. This
 improvement was not extended properly to term *updating*. As it stands,
 attempting to edit a term so that it has the same slug as an older term
 (ie a term with a lower term_id) - whether or not that term is in a
 different taxonomy, and whether the term being updated already has the
 shared slug or whether it's being updated to have that slug - the update
 will fail.

 Having spent some time looking at the duplicate checks in
 `wp_insert_term()` and `wp_update_term()`, I think that it may be a good
 idea to do a systematic overhaul for 4.2 so that (a) the duplicate
 restrictions are identical between the two functions, and (b) those
 restrictions are not overly conservative. But for 4.1.1, we can eliminate
 the immediate problems simply by swapping this duplicate check
 https://core.trac.wordpress.org/browser/tags/4.1/src/wp-
 includes/taxonomy.php#L3355 with one that is specific to the taxonomy.

 See [attachment:30780.3.patch] for my suggested fix for 4.1.1, with unit
 tests demonstrating the problem. dubh, ipm-frommen - feedback would be
 welcome on whether this sounds sane, and whether this simple fix resolves
 your issues.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30780#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list