Opened 7 years ago
Last modified 6 years ago
#42459 new defect (bug)
Comments metabox doesn't load all the comments when clicking "Show more comments" link
Reported by: | rku4er | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.8.3 |
Component: | Comments | Keywords: | |
Focuses: | javascript, administration | Cc: |
Description
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
<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 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, 10)
.
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
value.
I have tested it on my local end. It works well after I changed num
default value to 10.
Still running into this one.
Is there anything we should add that might make diagnosing the problem easier?
Thanks,
Eugen.