[wp-trac] [WordPress Trac] #21606: term_exists returns 0 and null

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 16 09:27:33 UTC 2012


#21606: term_exists returns 0 and null
--------------------------+-----------------------------
 Reporter:  barrykooij    |      Owner:  barrykooij
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  3.4.1
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------------
 The function ''term_exists'' in ''wp-includes/taxonomy.php'' has two
 different return values, ''0'' and ''null''. The function does a few
 checks and returns ''0'' if the condition of the check is not met. If the
 checks are met, the return value will be the result of a
 ''$wpdb->get_row'' or ''$wpdb->get_var''. If the term is not found in the
 database the methods ''get_row'' and ''get_var'' will return ''null''.

 Because of the different type of return values it's not possible to do a
 strict check on the return value to see if a term was found. I've changed
 the return ''0'' in ''term_exists'' to return ''null'', so that if there
 is no term found the result of ''term_exists'' will always be ''null''.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21606>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list