Make WordPress Core

Opened 7 years ago

Last modified 4 months ago

#46963 new defect (bug)

Comments meta box offset bug for custom comment types

Reported by: mikejolley's profile mikejolley 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:

https://github.com/WordPress/WordPress/blob/72979b167d913bf49745fa737654bdf6d13168de/wp-admin/js/post.js#L99

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:

https://github.com/WordPress/WordPress/blob/03240dd3f4442546562824bc6a10ed7c197bd6b2/wp-includes/comment-template.php#L466

<?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 comment class for custom comment types in addition to their custom class.
  • Revise jquery selector to be more generic e.g. count the tr elements instead.

Attachments (5)

46963.patch (1.9 KB) - added by hardipparmar 7 years ago.
I have fixed the "Comments meta box offset bug for custom comment types" issue.
46963.2.patch (1.9 KB) - added by hardipparmar 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.
Duplicate Reviews.png (467.6 KB) - added by sourabhjain 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
New Note.jpeg (712.2 KB) - added by poojapadamad 4 months ago.
New Note.2.jpeg (704.0 KB) - added by poojapadamad 4 months ago.

Download all attachments as: .zip

Change History (13)

#1 @SergeyBiryukov
7 years ago

  • Component changed from Administration to Comments
  • Focuses ui administration added

@hardipparmar
7 years ago

I have fixed the "Comments meta box offset bug for custom comment types" issue.

@hardipparmar
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 @hardipparmar
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.

#3 @andraganescu
7 years ago

  • Keywords has-patch needs-testing added

#4 @sainathpoojary
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

  1. Activate the “Simulate Comment Meta Box Offset Bug” plugin.
  2. Navigate to the Posts screen and open the post titled "Custom Comment Type Test".
  3. Scroll to the Comments meta box.
  4. Click “Show more comments”.
  5. 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

@sourabhjain
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: @sourabhjain
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

  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

https://core.trac.wordpress.org/attachment/ticket/46963/Duplicate%20Reviews.png

Last edited 4 months ago by sourabhjain (previous) (diff)

#7 in reply to: ↑ 6 @SirLouen
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 @poojapadamad
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

  1. ✅ Issue resolved with patch.

===Steps to reproduce:

  1. Install WooCommerce Plugin
  2. Create New Product
  3. Add Review
  4. Edit product
  5. 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

Last edited 4 months ago by poojapadamad (previous) (diff)
Note: See TracTickets for help on using tickets.