Ticket #2659 (assigned defect)

Opened 2 years ago

Last modified 7 months ago

Comment meta

Reported by: markjaquith Assigned to: markjaquith (accepted)
Priority: normal Milestone: 2.9
Component: General Version: 2.1
Severity: normal Keywords: comment meta needs-patch early
Cc:

Description

There was some discussion about comment meta (I think in a wp-meetup), but I can't find a ticket, so here it is.

There should be a commentmeta table that stores metadata associated with specific comments. This allows plugins to store data associated with specific comments, instead of trying to shoehorn it into postmeta somehow. Some possible uses:

  • Geo data
  • Additional fields (like a quiz, or the commenter's age, etc)
  • A link to the commenter's CoComment? feed
  • The name of the commenter's site
  • Comment subscription status (my plugin alters the comment table... something I wish could have been avoided)
  • Antispam plugin data related to the comment

Attachments

comment_meta_001.diff (10.7 kB) - added by markjaquith on 04/13/06 10:22:58.
Take 1
comment_meta_002.diff (12.6 kB) - added by markjaquith on 04/13/06 14:37:56.
Take 2

Change History

04/13/06 10:22:58 changed by markjaquith

  • attachment comment_meta_001.diff added.

Take 1

04/13/06 10:30:55 changed by markjaquith

  • keywords changed from comment meta to comment meta has-patch needs-testing.
  • status changed from new to assigned.

Take 1 is up. I bumped the WP DB version to 3673, which is current+1 as of this posting. After applying the patch, go to your wp-admin. If it doesn't say your DB is out of date, you'll have to manually UPDATE prefix_options SET option_value = '3672' WHERE option_name = 'db_version';

Test it out by using add_comment_meta(), delete_comment_meta(), and get_comment_meta(). They work exactly like their 'post' brethren, except that they take a comment id. In fact, the [add/delete/get]_[comment/post]_meta() functions are just pointers now to generic wp_[add/delete/get]_meta() functions whose last parameter is a string of 'comment' or 'post' ... these aren't meant to be used directly... they just save having 6 big functions when 3 flexible ones will do.

Things to test:

  • adding meta
  • updating meta
  • deleting meta
  • deleting a comment (make sure the meta goes too)
  • deleting a post (make sure all of its comments have their meta deleted)

Let me know how it goes.

04/13/06 14:37:56 changed by markjaquith

  • attachment comment_meta_002.diff added.

Take 2

04/13/06 14:39:17 changed by markjaquith

Take 2 adds automatic comment meta querying for all comments returned by comments_template()

04/14/06 08:12:56 changed by matt

This seems like somewhat edge functionality.

04/28/06 12:28:32 changed by markjaquith

Just today I came upon another instance where I would have liked to have had comment meta. I host pages about my WP plugins on my blog, and I get a lot of support questions on there. It would be nice to be able to have a "This is a support question" tick box for the comment form. I could then highlight them, or put them on my WP dashboard. When resolved, the meta value could change to something else and it would be marked as resolved. Bam, all of a sudden WP has basic support ticket capability.

If no one else thinks Comment Meta is a useful feature, I'll let it die, but I think there are a lot of plugin authors who could put this to good use, and really expand what is possible with WP.

04/28/06 12:46:24 changed by MikeLittle

I too think this is a good idea. I recently had to add voluntary capture of company and occupation to a WordPress comment form. Whilst I used filters and actions for some of the work. I ended up adding columns to the wp_comments table! Meta data would have been great! +1 from me. I'll try to d/load your patch and see if I could have implemented what I needed with it.

08/30/06 11:16:53 changed by markjaquith

Alright... last plea for this one. Yea or nay, people. I still hold that it could really open WP up to some cool plugin functionality. If all else fails, I can release it as a plugin that other plugin authors can use (similar to Skippy's wp-cron plugin).

08/30/06 16:44:27 changed by ryan

I don't have a burning desire for it, but I'll give it the ole plusone.

08/30/06 21:45:12 changed by mdawaffe

I like.

08/30/06 23:55:35 changed by markjaquith

I'll have to rework the patch, which I'll do if I get the official thumbs up. Let me know.

11/23/06 12:10:47 changed by McShelby

The Favatar plugin also adds new columns to the comments table in lack of a commentsmeta table. I would appreciate to have commentsmeta table.

12/01/06 02:53:31 changed by matt

  • milestone changed from 2.1 to 2.2.

03/27/07 21:02:25 changed by foolswisdom

  • milestone changed from 2.2 to 2.3.

05/25/07 22:46:08 changed by technosailor

+1

Is this patch needing refreshing?

09/01/07 10:00:08 changed by westi

  • milestone changed from 2.3 to 2.4 (next).

+1 for the idea.

It's too late for 2.3 though.

Pushing to 2.4 - lets get the framework for this in early.

Things that would be nice to store in comment_meta in the core:

  1. Outcome of the built in spam checks.

Should we move to a single generic "meta" table rather than a table for each type of meta (post|comment|....)?

(follow-up: ↓ 17 ) 09/01/07 14:01:43 changed by intoxination

I'm not to sure about this. What kind of performance impact will it have on blogs that see heavy comments? I'm thinking of sites that get 1,000+ comments a day, with some posts getting 300+ comments.

09/01/07 14:22:01 changed by filosofo

Would there be a significant performance hit if we just had a general object meta, for posts, users, comments, links, or whatever? It might be better than filling up the options table, which is what a number of plugins do when they need meta-data but don't have enough to warrant creating their own table.

(in reply to: ↑ 15 ) 09/01/07 14:29:16 changed by westi

Replying to intoxination:

I'm not to sure about this. What kind of performance impact will it have on blogs that see heavy comments? I'm thinking of sites that get 1,000+ comments a day, with some posts getting 300+ comments.

There is some performance impact.

Most of it though is inserting stuff in the database rather than quering the meta - i would not expect the meta to be autoloaded by queried on demand.

There are already plugins that do this themselves with there own tables (SK2 for example has a table for storing it's meta info about a comment)

09/01/07 20:13:51 changed by markjaquith

  • keywords changed from comment meta has-patch needs-testing to comment meta needs-patch.

We don't have to load it unless we're going to use it. But if we do load-on-demand, it would make sense to query commentdata for the entire $post->ID when the first request comes in. If we store a secondary id (the post ID), we could query them without any joins.

And yeah, it might be worth moving to a generic metadata table.

  1. No new tables
  2. Term meta
  3. Plugin meta

09/01/07 22:15:21 changed by matt

This discussion is going in weird places, it'd probably be best to consider:

  1. What are specific use cases we hope to enable.
  2. What is the most flexible way to do that, and the least flexible way.
  3. What new overhead is introduced, and how much new code does it create.
  4. How much of our userbase do we hope to use this.

Also maybe a forum like wp-hackers would be more appropriate.

09/13/07 03:59:32 changed by foolswisdom

  • keywords changed from comment meta needs-patch to comment meta needs-patch early.

02/12/08 09:37:34 changed by pishmishy

  • milestone changed from 2.5 to 2.6.

Bumping milestone for feature freeze.