#51305 closed defect (bug) (worksforme)
wp_list_comments returns nothing if "per_page" parameter is defined
Reported by: | SGr33n | Owned by: | metalandcoffee |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.5.1 |
Component: | Comments | Keywords: | needs-patch needs-unit-tests |
Focuses: | Cc: |
Description
Hi,
The function wp_list_comments returns a notice if "per_page" parameter is defined.
The notice is in wp-includes/comments-template.php
wp_queue_comments_for_comment_meta_lazyload( $_comments )
message: "Undefined variable: _comments"
Thanks!
Change History (8)
#3
@
4 years ago
Hi @metalandcoffee,
At first test looks working on the latest version.
Will keep you updated
Thanks!
#4
@
4 years ago
First test, working:
<?php wp_list_comments( array( 'page' => 1, 'per_page' => 10, 'style' => 'div', ) );
Second test (non working):
<?php wp_list_comments( array( 'page' => 1, 'per_page' => absint( get_option( 'comments_per_page' ) ), 'style' => 'div', ) );
Is returning
[12-Dec-2020 17:07:55 UTC] PHP Notice: Undefined variable: _comments in /web/wp-includes/comment-template.php on line 2236 [12-Dec-2020 17:07:55 UTC] PHP Notice: Undefined variable: _comments in /web/wp-includes/comment-template.php on line 2244
PHP version 7.4
PHP-FPM
Webserver Nginx
WordPress version 5.6
#5
@
3 years ago
I'm unable to replicate the issue in current master
branch (commit 02e9222e2ebaf97c75623112ad2370740a8db6a5
).
#6
@
19 months ago
I could not replicate this issue on PHP 7.4 with the latest version of WordPress.
Note: See
TracTickets for help on using
tickets.
Hi @SGr33n - I tried to reproduce this error by calling
wp_list_comments( array( 'per_page' => 1 ) );
but I'm not getting any PHP notices when this happens. Can you give steps to reproduce and provide all of the parameters you're using inwp_list_comments
? How many comments are you expecting to see on the post in question? What is your PHP version?