Skip to content

Conversation

@obenland
Copy link
Member

Proposed changes:

  • When Reader UI is disabled, the create_posts option may also be disabled. However, existing ap_post entries can still receive incoming fediverse replies, which would create comments and trigger email notifications.
  • This change adds a check in Interactions::persist() to reject comments on ap_post when the create_posts option is disabled, preventing unwanted notifications.

Other information:

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

Testing instructions:

  1. Enable Reader UI (which forces create_posts on)
  2. Follow some accounts and let some ap_post posts be created
  3. Disable Reader UI
  4. Have someone on the fediverse reply to one of the ap_post posts
  5. Verify that no comment is created and no notification email is sent

Changelog entry

Changelog entry was added manually via composer changelog:add.

When the Reader UI is disabled, the create_posts option may also be disabled,
but existing ap_post entries can still receive incoming fediverse replies.
Previously, these comments would be created and trigger email notifications.

This change adds a check in Interactions::persist() to reject comments on
ap_post when the create_posts option is disabled, preventing unwanted
notifications.
Copilot AI review requested due to automatic review settings December 18, 2025 12:31
@obenland obenland self-assigned this Dec 18, 2025
@obenland obenland requested a review from a team December 18, 2025 12:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents comments and reactions on ap_post entries when the create_posts option is disabled. When Reader UI is disabled, existing ap_post entries could still receive incoming fediverse replies, creating unwanted comments and email notifications. The solution adds an early check in the Interactions::persist() method to reject these interactions.

  • Adds validation in persist() to check if target post is ap_post and create_posts is disabled
  • Updates existing tests to explicitly enable create_posts option where needed
  • Adds comprehensive test coverage for the new behavior with three new test cases

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
includes/collection/class-interactions.php Adds check in persist() method to reject comments/reactions on ap_post when create_posts option is disabled
tests/phpunit/tests/includes/collection/class-test-interactions.php Updates existing tests to explicitly set create_posts option and adds three new tests covering disabled/enabled scenarios for comments and reactions
.github/changelog/fix-ap-post-comments-when-create-posts-disabled Adds changelog entry documenting the fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

*/
public static function persist( $comment_data, $action = self::INSERT ) {
// Don't allow comments on ap_post if create_posts is disabled.
if ( is_ap_post( $comment_data['comment_post_ID'] ) && '1' !== \get_option( 'activitypub_create_posts', false ) ) {
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option check uses strict string comparison '1' !== \get_option(...), which is inconsistent with other parts of the codebase. For example, includes/class-comment.php lines 707 and 771, and includes/handler/class-update.php line 97 use truthy checks without strict comparison. While this follows the pattern in includes/class-mailer.php, consider using a consistent approach throughout the codebase. The strict comparison is more explicit and safer since WordPress options are typically stored as strings.

Copilot uses AI. Check for mistakes.
@pfefferle
Copy link
Member

I think it is fine to add comments to an ap_post if there is one. The root-cause is that we decided to no longer check for the setting to be checked in the Reader PR.

@obenland
Copy link
Member Author

Closing in favor of #2667.

@obenland obenland closed this Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants