Skip to content

Fill in defaults for registered comment types - #3982

Merged
pfefferle merged 2 commits into
trunkfrom
fix/comment-type-defaults
Oct 28, 2026
Merged

pfefferle merged 2 commits into
trunkfrom
fix/comment-type-defaults

Conversation

@pfefferle

Copy link
Copy Markdown
Member

Fixes #

Proposed changes:

  • register_comment_type() now fills in defaults for every key the plugin reads (label, singular, type, collection, activity_types, excerpt, count_single, count_plural, …). Before, it stored the arguments as given, so a type registered by another plugin with only some of them caused Undefined array key warnings, e.g. in Comment::get_comment_type_by_activity_type() and the reactions REST endpoint.
  • The Jetpack integration now also passes the registered comment types to Jetpack, not only the hardcoded like, quote and repost. Those three stay, because the registered types are only known after init.

Other information:

  • Have you written new tests for your changes, if applicable?

I found this through a local demo mu-plugin that registers mention, bookmark and paper with only a label and the count strings. With it, ten tests failed locally while CI stayed green.

Testing instructions:

  • Run vendor/bin/phpunit --filter 'Test_Functions_Comment|Test_Comment|Test_Post_Controller|Test_Jetpack'.
  • Register a comment type with only a label, e.g. \Activitypub\register_comment_type( 'bookmark', array( 'label' => 'Bookmarks' ) ); in a mu-plugin, and open a post with reactions: no PHP warnings.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

@pfefferle pfefferle added the Bug Something isn't working label Oct 28, 2026
@pfefferle pfefferle self-assigned this Oct 28, 2026
@pfefferle
pfefferle requested a review from a team October 28, 2026 11:23
@github-actions github-actions Bot added [Focus] Compatibility Ensuring the plugin plays well with other plugins [Tests] Includes Tests labels Oct 28, 2026
@pfefferle
pfefferle merged commit 0dc6621 into trunk Oct 28, 2026
11 checks passed
@pfefferle
pfefferle deleted the fix/comment-type-defaults branch October 28, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working [Focus] Compatibility Ensuring the plugin plays well with other plugins [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant