WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#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: agalindo Owned by:
Priority: normal Milestone:
Component: General Version: 3.1
Severity: normal Keywords:
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 (3)

comment:1 follow-up: nacin2 years ago

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.

comment:2 in reply to: ↑ 1 agalindo2 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.

Version 0, edited 2 years ago by agalindo (next)

comment:3 ryan2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

It is indeed confusing. A taxonomy API cleanup will happen some day. In the mean time this is what we have.

Last edited 2 years ago by ryan (previous) (diff)
Note: See TracTickets for help on using tickets.