[wp-trac] [WordPress Trac] #36878: get_term_by returns random result with multiple terms

WordPress Trac noreply at wordpress.org
Wed May 18 15:34:47 UTC 2016


#36878: get_term_by returns random result with multiple terms
--------------------------+-----------------------------
 Reporter:  cogmios       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  4.5.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 '''current situation''': Taxonomy term names are not unique. GET_TERM_BY
 allows a developer to add a query for name. If multiple names are present
 e.g.:

 \legal\public\contract
 \finance\leasing\contract

 it will return a random one of the two because of LIMIT 1. A developer who
 creates code without the content yet in place, could create a bug by only
 realizing much later that multiple entries exist in the content or never
 even face the bug since sometimes it delivers the correct one and
 sometimes it does not. So in the end, the end-user will have to notify the
 developer something strange is going on...

 '''proposal''': the code should protect the developer from introducing
 bugs. So proposal to either

 - return multiple (remove limit 1) (can't see why not) or
 - return WP_ERROR if multiple so it is at least clear there is a bug
 - or not allow names

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36878>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list