@@ -564,7 +564,7 @@ function get_comment_class( $css_class = '', $comment_id = null, $post = null )
564564 ++$ comment_alt ;
565565
566566 // Alt for top-level comments.
567- if ( 1 == $ comment_depth ) {
567+ if ( 1 === $ comment_depth ) {
568568 if ( $ comment_thread_alt % 2 ) {
569569 $ classes [] = 'thread-odd ' ;
570570 $ classes [] = 'thread-alt ' ;
@@ -814,9 +814,9 @@ function get_comment_link( $comment = null, $args = array() ) {
814814
815815 $ cpage = $ args ['page ' ];
816816
817- if ( '' == $ cpage ) {
817+ if ( '' === $ cpage ) {
818818 if ( ! empty ( $ in_comment_loop ) ) {
819- $ cpage = get_query_var ( 'cpage ' );
819+ $ cpage = ( int ) get_query_var ( 'cpage ' );
820820 } else {
821821 // Requires a database hit, so we only do it when we can't figure out from context.
822822 $ cpage = get_page_of_comment ( $ comment ->comment_ID , $ args );
@@ -1605,7 +1605,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false
16051605
16061606 $ overridden_cpage = false ;
16071607
1608- if ( '' == get_query_var ( 'cpage ' ) && $ wp_query ->max_num_comment_pages > 1 ) {
1608+ if ( '' === get_query_var ( 'cpage ' ) && $ wp_query ->max_num_comment_pages > 1 ) {
16091609 set_query_var ( 'cpage ' , 'newest ' === get_option ( 'default_comments_page ' ) ? get_comment_pages_count () : 1 );
16101610 $ overridden_cpage = true ;
16111611 }
@@ -2291,13 +2291,13 @@ function wp_list_comments( $args = array(), $comments = null ) {
22912291 * perform a separate comment query and allow Walker_Comment to paginate.
22922292 */
22932293 if ( $ parsed_args ['page ' ] || $ parsed_args ['per_page ' ] ) {
2294- $ current_cpage = get_query_var ( 'cpage ' );
2294+ $ current_cpage = ( int ) get_query_var ( 'cpage ' );
22952295 if ( ! $ current_cpage ) {
22962296 $ current_cpage = 'newest ' === get_option ( 'default_comments_page ' ) ? 1 : $ wp_query ->max_num_comment_pages ;
22972297 }
22982298
2299- $ current_per_page = get_query_var ( 'comments_per_page ' );
2300- if ( $ parsed_args ['page ' ] != $ current_cpage || $ parsed_args ['per_page ' ] != $ current_per_page ) {
2299+ $ current_per_page = ( int ) get_query_var ( 'comments_per_page ' );
2300+ if ( ( int ) $ parsed_args ['page ' ] !== $ current_cpage || ( int ) $ parsed_args ['per_page ' ] != = $ current_per_page ) {
23012301 $ comment_args = array (
23022302 'post_id ' => get_the_ID (),
23032303 'orderby ' => 'comment_date_gmt ' ,
@@ -2348,15 +2348,15 @@ function wp_list_comments( $args = array(), $comments = null ) {
23482348
23492349 if ( $ wp_query ->max_num_comment_pages ) {
23502350 $ default_comments_page = get_option ( 'default_comments_page ' );
2351- $ cpage = get_query_var ( 'cpage ' );
2351+ $ cpage = (int ) get_query_var ( 'cpage ' );
2352+
23522353 if ( 'newest ' === $ default_comments_page ) {
23532354 $ parsed_args ['cpage ' ] = $ cpage ;
2354-
2355+ } elseif ( 1 === $ cpage ) {
23552356 /*
2356- * When first page shows oldest comments, post permalink is the same as
2357- * the comment permalink.
2358- */
2359- } elseif ( 1 == $ cpage ) {
2357+ * When the first page shows the oldest comments,
2358+ * post permalink is the same as the comment permalink.
2359+ */
23602360 $ parsed_args ['cpage ' ] = '' ;
23612361 } else {
23622362 $ parsed_args ['cpage ' ] = $ cpage ;
@@ -2389,14 +2389,16 @@ function wp_list_comments( $args = array(), $comments = null ) {
23892389 if ( empty ( $ overridden_cpage ) ) {
23902390 $ parsed_args ['page ' ] = get_query_var ( 'cpage ' );
23912391 } else {
2392- $ threaded = ( -1 != $ parsed_args ['max_depth ' ] );
2392+ $ threaded = ( -1 !== ( int ) $ parsed_args ['max_depth ' ] );
23932393 $ parsed_args ['page ' ] = ( 'newest ' === get_option ( 'default_comments_page ' ) ) ? get_comment_pages_count ( $ _comments , $ parsed_args ['per_page ' ], $ threaded ) : 1 ;
23942394 set_query_var ( 'cpage ' , $ parsed_args ['page ' ] );
23952395 }
23962396 }
2397+
23972398 // Validation check.
2398- $ parsed_args ['page ' ] = (int ) $ parsed_args ['page ' ];
2399- if ( 0 == $ parsed_args ['page ' ] && 0 != $ parsed_args ['per_page ' ] ) {
2399+ $ parsed_args ['page ' ] = (int ) $ parsed_args ['page ' ];
2400+ $ parsed_args ['per_page ' ] = (int ) $ parsed_args ['per_page ' ];
2401+ if ( 0 === $ parsed_args ['page ' ] && 0 !== $ parsed_args ['per_page ' ] ) {
24002402 $ parsed_args ['page ' ] = 1 ;
24012403 }
24022404
0 commit comments