#18009 closed defect (bug) (wontfix)
term_exists uses is_int so '0' does not equal 0 and so wp_set_object_terms will create 0
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
If setting object terms and one has not type casted string 0 to integer 0 then term_exists will see this as a category name and return false, the category 0 does not exists and wp_set_object_terms will create it.
It exists on line 1452 of taxonomy.php (http://core.trac.wordpress.org/browser/tags/3.2/wp-includes/taxonomy.php#L1452)
The fix is simple, switching is_int to is_numeric
Change History (4)
#2
in reply to:
↑ 1
@
14 years ago
Replying to nacin:
That's actually proper behavior. The term API makes a distinct difference between a numeric string, treating it as a slug, and an integer, which it treats as an ID.
It seems rather counter-intuitive to the normal PHP workflow (ignoring types, that is) to make that sort of behavior built into the term API.
Note: See
TracTickets for help on using
tickets.
That's actually proper behavior. The term API makes a distinct difference between a numeric string, treating it as a slug, and an integer, which it treats as an ID.