Repository navigation
Keep comments of named posts in admin comment queries - #4039
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #4030
Proposed changes:
Comment::comment_query()replaced thepost_typeof 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 hitwc_get_order_notes(), which asks forpost_idandtype => 'order_note'. Orders are not in that list (classic storage), or not inwp_postsat 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.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 namedap_poststay hidden, astest_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_typestill 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:
Two tests: notes of a named
shop_orderpost, bypost_idandpost__in, and notes of an object that is not inwp_posts, as orders with HPOS. Both fail without the change.Testing instructions:
Changelog entry
Changelog entry added in
.github/changelog/fix-woocommerce-order-notes(Patch / Fixed).