Skip to:
Content

bbPress.org

Opened 4 years ago

Closed 3 months ago

#3436 closed defect (bug) (fixed)

register_meta() calls should use 'object_subtype' argument

Reported by: r-a-y's profile r-a-y Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 2.7 Priority: normal
Severity: normal Version: 2.6.0
Component: API Keywords: has-patch
Cc:

Description

bbPress registers various meta keys, but doesn't set the 'object_subtype' argument:
https://bbpress.trac.wordpress.org/browser/branches/2.6/src/bbpress.php?marks=778-787#L768

Currently, this means any post that is published will receive the following meta keys regardless of bbPress post type:

  • _bbp_topic_count
  • _bbp_reply_count
  • _bbp_total_topic_count
  • _bbp_total_reply_count
  • _bbp_voice_count
  • _bbp_anonymous_reply_count
  • _bbp_topic_count_hidden
  • _bbp_reply_count_hidden
  • _bbp_forum_subforum_count

I've attached a patch that only registers meta keys for the correct bbPress forum and topic post types.

Attachments (2)

3436.01.patch (1.3 KB) - added by r-a-y 4 years ago.
3436.02.patch (1.7 KB) - added by r-a-y 4 years ago.

Download all attachments as: .zip

Change History (9)

@r-a-y
4 years ago

#1 @r-a-y
4 years ago

Could also use register_post_meta() in place of register_meta() instead.

Ignore 01.patch, use 02.patch.

Last edited 4 years ago by r-a-y (previous) (diff)

@r-a-y
4 years ago

#2 @hasanuzzamanshamim
4 years ago

  • Keywords has-patch added

#3 @r-a-y
2 years ago

#3588 was marked as a duplicate.

#4 @r-a-y
4 months ago

Bumping this one as this was mentioned recently in #3588.

#5 @johnjamesjacoby
3 months ago

  • Milestone changed from Awaiting Review to 2.7
  • Owner set to johnjamesjacoby
  • Status changed from new to assigned

#6 @johnjamesjacoby
3 months ago

Let's not use register_post_meta().

There is no register_user_meta() equivalent, and I'd like to keep the code patterned similarly if possible.

I'll be committing a modified version of @r-a-y's first patch, because a few of the meta keys are available to both forums and topics.

#7 @johnjamesjacoby
3 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 7351:

Meta: pass post-type into relevant calls to register_meta().

This change ensures that these bbPress meta keys are not associated with other custom post-types, particularly when using the REST API.

Props r-a-y, terresquall.

See #3588.

Fixes #3436.

Note: See TracTickets for help on using tickets.