[wp-trac] [WordPress Trac] #36949: Term exists should use get_terms internally

WordPress Trac noreply at wordpress.org
Tue Jan 8 03:02:47 UTC 2019


#36949: Term exists should use get_terms internally
--------------------------------------------+-----------------------------
 Reporter:  spacedmonkey                    |       Owner:  (none)
     Type:  enhancement                     |      Status:  new
 Priority:  normal                          |   Milestone:  Future Release
Component:  Taxonomy                        |     Version:  2.3
 Severity:  normal                          |  Resolution:
 Keywords:  has-patch has-unit-tests close  |     Focuses:  performance
--------------------------------------------+-----------------------------
Changes (by boonebgorges):

 * keywords:  has-patch has-unit-tests => has-patch has-unit-tests close


Comment:

 Thanks for the patch, @spacedmonkey. The `WP_IMPORTING` check is clever.
 But it's also ad hoc, which makes me nervous. If wordpress-importer
 expects `term_exists()` to query the database directly, then it's likely
 that other plugins in the wild are doing the same thing.

 I mentioned in https://core.trac.wordpress.org/ticket/36949#comment:4 that
 we might consider simply leaving `term_exists()` as is, but phasing out
 its use in core. To me, this feels like a much safer option. The fact that
 `term_exists()` accepts IDs or slugs or names means that it's already
 subject to all sorts of bugs related to similarly named terms (I'm too
 lazy to search for tickets, but I'm sure you could find lots). This
 ambiguity is almost always bad, and is the reason why we have
 `get_term_by()`.

 As such, I'd much rather spend effort phasing out the internal use of
 `term_exists()`, rather than making the proposed internal change (which
 has somewhat marginal benefit) and then dealing with the inevitable
 compatibility cleanups. Does this seems reasonable?

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


More information about the wp-trac mailing list