WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 4 months 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:
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)

comment:1 follow-up: nacin3 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 agalindo3 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 3 years ago by agalindo (next)

comment:3 ryan3 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 3 years ago by ryan (previous) (diff)

comment:4 SergeyBiryukov4 months ago

  • Component changed from General to Taxonomy
Note: See TracTickets for help on using tickets.