Ticket #5183 (new enhancement)

Opened 7 months ago

Last modified 3 months ago

General Meta-Data Table

Reported by: filosofo Assigned to: anonymous
Priority: normal Milestone: 2.6
Component: General Version: 2.3
Severity: normal Keywords: meta-table meta has-patch
Cc: filosofo

Description

As I proposed on wp-hackers, it would be great to have a general meta table.

There are at least a couple of benefits to such a table:

  • We could have meta-data for comments and categories.

Others have proposed meta tables for the comments (e.g. #5153 and #2659); rather than adding meta tables seriatim, a general meta-data table would meet that need and offer the possibility of actually reducing the total number of tables.

  • It would provide a better place for plugins to store data.

Currently, most plugins---when they don't have enough data to justify creating their own table---store data in the options table. I think there are disadvantages to bloating the options table, one of which is that WP loads almost all options into the object cache.

My attached patch includes the code necessary get such a table working in WP (aside from decrementing the db_version), and I've tested each of the get_general_meta, update_general_meta, and delete_general_meta functions successfully.

By the way, update_meta and delete_meta would have been cleaner names, but they're already taken for admin post meta stuff.

Attachments

general_meta_table.diff (4.4 kB) - added by filosofo on 10/11/07 20:24:11.

Change History

10/11/07 20:05:43 changed by westi

+1

Some notes from a quick first pass of the patch:

  1. You need to create (or find) a meta_key sanitization function - duplicated preg_replace's are bad.
  2. Doesn't ->prepare escape the data for you?/prepa
  3. db_insert and db_update should probably me used now they exists ;-)

10/11/07 20:24:11 changed by filosofo

  • attachment general_meta_table.diff added.

10/11/07 20:31:55 changed by filosofo

  1. I was thinking about using sanitize_title, but I wondered if there was some reason someone uses this regex in the user meta functions to exclude dashes.
  2. I've updated the patch to take out the extraneous escape.
  3. I've updated the patch to use db_insert, but db_update is no good, as it allows you to specify only one column in the where clause.

10/12/07 00:25:38 changed by Otto42

General thoughts that I can think of right now:

I agree with Marcos' opinion on wp-hackers: Change meta_type to object_type.

I didn't think about this when designing the table schema, but having a NULL meta_key makes no sense that I can think of. Change it to NOT NULL with no default. Force the entry to have a defined key.

12/22/07 03:27:43 changed by darkdragon

I would really like to see this be included in WordPress!

I'm referencing #3364, since it has to do with metadata db improvements.

02/26/08 10:10:12 changed by ryan

  • milestone changed from 2.5 to 2.6.