Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#39814 closed defect (bug) (wontfix)

wp_usermeta uses umeta_id instead of meta_id

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by:
Milestone: Priority: normal
Severity: normal Version: 0.71
Component: Database Keywords:
Focuses: Cc:

Description

The wp_usermeta database table has an inconsistency compared to all other meta-data tables, in that it's meta_id column is named umeta_id. It has always had this, but there hasn't been a ticket on Trac specifically for this that I could see (even if we decide to close it right away.)

This discrepancy requires work-arounds in WordPress core, specifically in the meta-data API. (See #11627.)

There are a few ways to look at this:

  • Legacy, so we're stuck with it
  • Benign, so leave it alone
  • Changing it may cause more harm than good, so ignore it

Personally, it's uniqueness bothers my OCD more than supporting a schema change would, so my vote is to: rename it in a database upgrade, upgrade core's related database queries, and add pre-flight string-replace to WPDB to protect custom queries from failing.

Change History (3)

#1 @1naveengiri
7 years ago

  • Keywords dev-feedback added

I like the point.
It should be meta_id as we already following same name for all meta-data tables.
It should considered as Bug. even it is not any issue with functionality but still for standards.

#2 @dd32
7 years ago

  • Keywords close added

In an ideal world everything would be named consistently - but it's not, instead we put consistent API's in front of it so that others shouldn't need worry about these small nuances.

I don't think we should be changing anything here, definitely not renaming the column, as it potentially breaks compatibility while not actually gaining much (code already exists to work around the name difference). We could work around queries using the old column name - but doing so doesn't seem worth it.

If there's any locations in the meta api where we return the key umeta_id and meta_id in other cases, then updating it so as to cause usermeta to return [umeta_id => ..., meta_id => ..., ...] would seem sane - once again, so as to add a consistent API.

#3 @pento
5 years ago

  • Keywords 2nd-opinion dev-feedback close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

There's no practical way for us to rename this column without breaking a whole lot of third party code. Even if we bumped the minimum MySQL version to 5.7 (so we could use generated columns to keep a generated umeta_id column for back compat), that would only help for read queries, not write queries.

Note: See TracTickets for help on using tickets.