Make WordPress Core

Opened 4 years ago

Closed 16 months ago

Last modified 5 months ago

#51305 closed defect (bug) (worksforme)

wp_list_comments returns nothing if "per_page" parameter is defined

Reported by: sgr33n's profile SGr33n Owned by: metalandcoffee's profile metalandcoffee
Milestone: Priority: normal
Severity: normal Version: 5.5.1
Component: Comments Keywords: needs-patch needs-unit-tests
Focuses: Cc:


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"


Change History (8)

#1 @SergeyBiryukov
4 years ago

  • Keywords needs-patch needs-unit-tests added

#2 @metalandcoffee
4 years ago

  • Owner set to metalandcoffee
  • Status changed from new to assigned

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 in wp_list_comments? How many comments are you expecting to see on the post in question? What is your PHP version?

#3 @SGr33n
4 years ago

Hi @metalandcoffee,
At first test looks working on the latest version.
Will keep you updated

#4 @SGr33n
4 years ago

First test, working:

                        'page'                  => 1,
                        'per_page'              => 10,
                        'style'                 => 'div',

Second test (non working):

                        '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
Webserver Nginx
WordPress version 5.6

#5 @donmhico
3 years ago

I'm unable to replicate the issue in current master branch (commit 02e9222e2ebaf97c75623112ad2370740a8db6a5).

#6 @Howdy_McGee
16 months ago

I could not replicate this issue on PHP 7.4 with the latest version of WordPress.

#7 @SGr33n
16 months ago

  • Resolution set to worksforme
  • Status changed from assigned to closed

I can confirm it's not happening anymore.
Maybe this was fixed over these two years.

#8 @swissspidy
5 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.