[wp-trac] [WordPress Trac] #42459: Comments metabox doesn't load all the comments when clicking "Show more comments" link

WordPress Trac noreply at wordpress.org
Tue Nov 7 18:04:19 UTC 2017

#42459: Comments metabox doesn't load all the comments when clicking "Show more
comments" link
 Reporter:  rku4er                      |      Owner:
     Type:  defect (bug)                |     Status:  new
 Priority:  normal                      |  Milestone:  Awaiting Review
Component:  Comments                    |    Version:  4.8.3
 Severity:  normal                      |   Keywords:
  Focuses:  javascript, administration  |
 Recently, I found an issue related to the Comments meta-box on a post edit
 screen. To reproduce the bug, go to the article with a certain number of
 comments. Suppose there are 25 comments. Then go to the post edit screen,
 enable the comments and scroll down to view all the comments(you will see
 10). Then click the link "Show more comments" at the bottom of the
 section. You will see the second part of the comments (10 again), and the
 link "Show more comments" will disappear. You may notice that you can't
 load the remaining comments(5).

 Why this happened? My short investigation below.

 I found that on my opinion there is a mismatch in amount of loaded
 comments between the ''commentBox'' object(`/wp-admin/js/post.js`) and
 comments meta-box init script(`/wp-admin/includes/meta-boxes.php`).

 First have a look at `/wp-admin/includes/meta-boxes.php:741`
 echo $total; ?>, 10);});</script>

 As you can see there are 10 comments set to be loaded.

 Then go to `/wp-admin/js/post.js:42-45`
 if ( ! num )
   num = 20;

 this.st += num;

 As you can see there is default `num` value set to 20. Important: then
 commentBox.st was increased by a `num` value.

 But now have a look at "Show more comments" link onclick attribute.
 <a href="#commentstatusdiv" onclick="commentsBox.load(26);return
 false;">Show more comments</a>

 As you can see `commentsBox.load(26)` call will update `commentBox.st` but
 then `commentBox.get(26, 20)` will be called (because `num = 20`). But to
 fit the init script(`meta-boxes.php`) it should be `commentBox.get(26,

 My solution here is to set default `num` value to 10. So I guess `/wp-
 admin/js/post.js:42` should looks like this:
 if ( ! num )
   num = 10;

 Let me know if I missed something and we can't accept new default `num`
 I have tested it on my local end. It works well after I changed `num`
 default value to 10.

Ticket URL: <https://core.trac.wordpress.org/ticket/42459>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list