[wp-trac] [WordPress Trac] #37686: Add object_type column to term_relationships table

WordPress Trac noreply at wordpress.org
Wed Aug 17 10:32:25 UTC 2016


#37686: Add object_type column to term_relationships table
-----------------------------+-----------------------------
 Reporter:  johnjamesjacoby  |      Owner:
     Type:  enhancement      |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Taxonomy         |    Version:
 Severity:  normal           |   Keywords:  2nd-opinion
  Focuses:                   |
-----------------------------+-----------------------------
 '''Prologue'''

 Today in WordPress core, taxonomy terms are only ever registered to post
 objects. This makes it easy to discern that in the `wp_term_relationships`
 database table, every `object_id` points to a post ID from the `wp_posts`
 database table.

 ----

 '''Problem'''

 When using taxonomies for things other than posts, it's impossible to
 discern the type of object that a taxonomy term is related to.

 ----

 '''Example'''

 The WP User Groups plugin registers taxonomies for users, and uses the
 `object_id` column for user IDs from the `wp_users` database table
 (instead of post IDs.)

 This means that a taxonomy term ID cannot be used for both post ID's and
 user ID's, as there is no way to know if an `object_id` is for a post ID
 or a user ID.

 ----

 '''Solution'''

 Introduce an additional column in the `wp_term_relationships` table for an
 `object_type`. Core object types would be registered according to their
 primary function: `post`, `comment`, `user`, and heck... even `term`,
 `option`, `site`, or `network` could make for interesting taxonomy term
 relationships.

 This change also -- relatively easily -- allows for many-to-many object-
 to-object relationships, where posts, comments, and users can share a
 common tag or category, without being required to.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37686>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list