[wp-trac] [WordPress Trac] #5381: type mismatch between is_term and
get_term_by
WordPress Trac
wp-trac at lists.automattic.com
Fri Nov 23 10:26:28 GMT 2007
#5381: type mismatch between is_term and get_term_by
------------------------+---------------------------------------------------
Reporter: tellyworth | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.5
Component: General | Version:
Severity: normal | Keywords:
------------------------+---------------------------------------------------
get_term_by() and similar functions return a row that includes the term_id
as a numeric string. is_term() requires that a term_id be passed in as an
int; a numeric string will fail.
I don't know what the solution is but this seems like a likely cause of
bugs. Code that looks like it ought to work fails:
{{{
$term_id = get_term_by('name', $term, $taxonomy);
if ( is_term($term_id) ) ... // fails because is_term returns
false
}}}
test_is_term_type() in http://svn.automattic.com/wordpress-tests/wp-
testcase/test_includes_taxonomy.php reproduces the problem.
There are other related type inconsistencies in taxonomy.php also - for
example, is_term() returns a 0, NULL, term ID, WP_Error object or row
object depending on the context and circumstances, which makes handling
the return result difficult. Mostly due I think to the functions being
overloaded to magically handle both term ids and names.
--
Ticket URL: <http://trac.wordpress.org/ticket/5381>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list