Opened 7 years ago
Last modified 4 months ago
#46963 new defect (bug)
Comments meta box offset bug for custom comment types
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Comments | Keywords: | has-patch needs-testing |
| Focuses: | ui, administration | Cc: |
Description
There is a conflict in the 'comments' meta box when used in combination with custom comment types.
The Show more comments link loads duplicates, without an offset due to this line of code:
this.st = jQuery('#the-comment-list tr.comment:visible').length;
For custom comment types, the comment class may not exist. See how comment classes are generated here:
<?php $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
You can see an example of this with WooCommerce which uses a comment type named 'review' (https://github.com/woocommerce/woocommerce/issues/23313). Because the comments out output without the comment class and instead they have a review class, the JS code fails to set the correct offset.
Possible solutions:
- Output
commentclass for custom comment types in addition to their custom class. - Revise jquery selector to be more generic e.g. count the
trelements instead.
Attachments (5)
Change History (13)
@
7 years ago
In the above patch, file patch is not included so I have created another patch. Please consider this new patch for this issue.
#2
@
7 years ago
46963.patch file in the file path is not included so I have created another patch. (46963.patch [46963.2.patch]) Please consider this new patch for this issue.
#4
@
5 months ago
Reproduction Report
Description
This report validates whether the offset bug in the Comments meta box for custom comment types can still be reproduced. The original issue mentions WooCommerce reviews as an example; however, this was not reproducible in current WooCommerce. To simulate the condition more precisely, I created a plugin that registers a custom_note comment type.
The bug occurs because core JavaScript expects a .comment class to be present when calculating the offset during "Show more comments" pagination. Custom comment types do not include this class by default.
Plugin used to simulate:
📎 https://gist.github.com/SainathPoojary/d6f39d0e45a3b2018f9312bdda1e26b5
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 137.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
- Classic Editor 1.6.7
- Simulate Comment Meta Box Offset Bug 1.0
- Test Reports 1.2.0
Steps to Reproduce
- Activate the “Simulate Comment Meta Box Offset Bug” plugin.
- Navigate to the Posts screen and open the post titled "Custom Comment Type Test".
- Scroll to the Comments meta box.
- Click “Show more comments”.
- Observe that the same comments are duplicated instead of paginated correctly.
Actual Results
✅ Error condition occurs (reproduced).
Additional Notes
- This bug is still reproducible in the current development version of WordPress.
- A patch previously proposed 46963.2 is no longer applying cleanly and need to be refreshed.
This ticket was mentioned in PR #9193 on WordPress/wordpress-develop by @sainathpoojary.
5 months ago
#5
Trac ticket: #46963
@
4 months ago
Test Report === Description This report validates whether the indicated this is still reproduce Patch tested: latest === Environment - WordPress: 6.8.2 - PHP: 8.2.27 - Server: Apache/2.4.62 (Debian) - Database: mysqli (Server: 11.4.5-MariaDB-ubu2404 / Client: mysqlnd 8.2.27) - Browser: Chrome 138.0.0.0 - OS: macOS - Theme: Twenty Twenty-Five 1.1 - MU Plugins: None activated - Plugins: * Test Reports 1.2.0 * WooCommerce 10.0.4 === Actual Results 1. Issue still reproduce in latest Wordpress version === Additional Notes Steps to Reproduce : > Install WooCommerce Plugin > Create New Product > Add Review > Edit product > Scroll down to see show more comments === Supplemental Artifacts
#6
follow-up:
↓ 7
@
4 months ago
Test Report
Description
This report validates whether the indicated this is still reproduce
Patch tested: Latest WordPress Version
Environment
- WordPress: 6.8.2
- PHP: 8.2.27
- Server: Apache/2.4.62 (Debian)
- Database: mysqli (Server: 11.4.5-MariaDB-ubu2404 / Client: mysqlnd 8.2.27)
- Browser: Chrome 138.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.1
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
- WooCommerce 10.0.4
Actual Results
- Issue still reproduce in latest WordPress version
Additional Notes
Steps to Reproduce :
Install WooCommerce Plugin
Create New Product
Add Review
Edit product
Scroll down to see show more comments
Supplemental Artifacts
https://core.trac.wordpress.org/attachment/ticket/46963/Duplicate%20Reviews.png
#7
in reply to:
↑ 6
@
4 months ago
Replying to sourabhjain:
Test Report
Description
This report validates whether the indicated this is still reproduce
@sourabhjain good job for testing 👌
Another little suggestion: In this case, instead of a Test Report, you can use the Reproduction Report template.
As you can see, this report doesn't have the "Patch Tested" part.
#8
@
4 months ago
Test Report
Description
This report validates whether the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/9193
Environment
- WordPress: 6.9-alpha-20250704.090409
- PHP: 7.4.31-dev
- Server: PHP.wasm
- Database: WP_SQLite_Driver (Server: 5.5 / Client: 3.40.1)
- Browser: Chrome 138.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
- WooCommerce 10.0.4
Actual Results
- ✅ Issue resolved with patch.
===Steps to reproduce:
- Install WooCommerce Plugin
- Create New Product
- Add Review
- Edit product
- Scroll down to see show more comments
Supplemental Artifacts
Attachments -
https://core.trac.wordpress.org/attachment/ticket/46963/New%20Note.jpeg
https://core.trac.wordpress.org/attachment/ticket/46963/New%20Note.2.jpeg
I have fixed the "Comments meta box offset bug for custom comment types" issue.