Skip to content

Keep comments of named posts in admin comment queries - #4039

Merged
pfefferle merged 2 commits into
trunkfrom
fix/woocommerce-order-notes
Nov 9, 2026
Merged

pfefferle merged 2 commits into
trunkfrom
fix/woocommerce-order-notes

Conversation

@pfefferle

Copy link
Copy Markdown
Member

Fixes #4030

Proposed changes:

  • In the admin, Comment::comment_query() replaced the post_type of every comment query with the post types that support comments, minus the hidden ones (ap_post). That keeps comments on cached remote posts out of the comment list and the counts, but it also hit wc_get_order_notes(), which asks for post_id and type => 'order_note'. Orders are not in that list (classic storage), or not in wp_posts at all (HPOS), so every order showed "No notes". This has been the case since Add hide_for method to Comment class #2662 made the restriction unconditional.
  • A query for named posts (post_id, post__in) is now only restricted when one of the named posts has a hidden post type. Comments of other posts are found again, also of objects that are not posts. Comments on a named ap_post stay hidden, as test_ap_post_comments_hidden_when_querying_specific_post() expects, and queries without named posts (comment list, counts, admin bar) are restricted as before.

Not changed here: an admin query that names no post but sets its own post_type still gets it replaced, and a query by comment type alone still gets the restriction. Neither is what WooCommerce does for order notes, and changing the replacement to a merge, as #3315 did for the comment types, would be its own change.

Other information:

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

Two tests: notes of a named shop_order post, by post_id and post__in, and notes of an object that is not in wp_posts, as orders with HPOS. Both fail without the change.

Testing instructions:

  • Activate WooCommerce and ActivityPub.
  • Open an order with notes under WooCommerce > Orders.
  • Before: "There are no notes yet." After: the notes are listed, with HPOS and with the legacy order storage.
  • Comments on posts from followed accounts still do not show under Comments.

Changelog entry

Changelog entry added in .github/changelog/fix-woocommerce-order-notes (Patch / Fixed).

@pfefferle pfefferle added the Bug Something isn't working label Nov 9, 2026
Copilot AI balanced review requested due to automatic review settings November 9, 2026 09:27
@pfefferle pfefferle self-assigned this Nov 9, 2026
@pfefferle
pfefferle requested a review from a team November 9, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The post__in check validates only the first ID in a comma-separated list, allowing admin queries to expose hidden ap_post comments.

1 open issue
What changed in this PR

This PR addresses #4030 by narrowing ActivityPub’s admin comment filtering so queries for specific items can retrieve WooCommerce order notes, including orders stored outside wp_posts.

Changes:

  • Bypasses the post-type restriction for explicitly named items unless a hidden post type is detected.
  • Adds regression tests for legacy order posts and objects stored outside wp_posts.
  • Adds a user-facing changelog entry.
File Description
tests/​phpunit/​tests/​includes/​class-test-comment.php Tests order-note queries by post ID, ID array, and an ID absent from wp_posts.
includes/​class-comment.php Makes admin post-type filtering conditional for queries naming specific items.
.github/​changelog/​fix-woocommerce-order-notes Announces restored visibility of order notes and other item-specific comments.

Review effort: Balanced

Comment thread includes/class-comment.php Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the comment-query filtering change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@pfefferle
pfefferle merged commit ea65305 into trunk Nov 9, 2026
12 checks passed
@pfefferle
pfefferle deleted the fix/woocommerce-order-notes branch November 9, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WooCommerce order notes hidden while ActivityPub is enabled

2 participants