[wp-trac] [WordPress Trac] #34533: Term splitting in `get_term()` can have unexpected effects

WordPress Trac noreply at wordpress.org
Thu Nov 5 16:45:02 UTC 2015


#34533: Term splitting in `get_term()` can have unexpected effects
--------------------------+---------------------------
 Reporter:  dlh           |       Owner:  boonebgorges
     Type:  defect (bug)  |      Status:  closed
 Priority:  high          |   Milestone:  4.4
Component:  Taxonomy      |     Version:  trunk
 Severity:  normal        |  Resolution:  fixed
 Keywords:  has-patch     |     Focuses:
--------------------------+---------------------------
Changes (by boonebgorges):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"35537"]:
 {{{
 #!CommitTicketReference repository="" revision="35537"
 Make `get_term()` behave more consistently in the context of shared terms.

 When `WP_Term` was introduced in [34997], the `$taxonomy` parameter for
 `get_term()` was made optional. This meant that, when the optional param
 was
 omitted, `get_term()` had no way of determining which term was intended
 when
 the term_id was shared between multiple taxonomies. As a (somewhat sneaky)
 way
 of fixing things, `get_term()` split any shared terms it found. But this
 could
 cause problems with developer expectations: it's not clear why requesting
 a
 term should result in a database update, much less a potential change in
 the
 ID of a term.

 In place of this technique, this changeset introduces a number of changes
 that
 make the handling of shared terms a bit less insane:

 * When a taxonomy is provided to `get_term()`, and a cached term is found
 matching the term_id, make sure the taxonomy also matches before returning
 it.
 * When a taxonomy is not provided, ensure that the term is not shared
 before adding it to the cache.
 * When a term is shared between taxonomies and no taxonomy is provided,
 return a `WP_Error` rather than splitting the term.
 * When a term is shared between taxonomies, only one of which is valid,
 return the term from that taxonomy.

 Props boonebgorges, dlh.
 Fixes #34533.
 }}}

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


More information about the wp-trac mailing list