Coding Standards: Use strict comparison in `wp_list_comments()`.

Follow-up to [8962], [9296], [9424], [34735], [36157].

Props deepakrohilla, sabernhardt, aristath, poena, afercia, SergeyBiryukov.
Fixes #62169. See #61607.
Built from https://develop.svn.wordpress.org/trunk@59183


git-svn-id: http://core.svn.wordpress.org/trunk@58578 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-10-06 16:56:19 +00:00
parent d13435cc58
commit 6c4dd50e88
2 changed files with 19 additions and 17 deletions

View File

@ -564,7 +564,7 @@ function get_comment_class( $css_class = '', $comment_id = null, $post = null )
++$comment_alt; ++$comment_alt;
// Alt for top-level comments. // Alt for top-level comments.
if ( 1 == $comment_depth ) { if ( 1 === $comment_depth ) {
if ( $comment_thread_alt % 2 ) { if ( $comment_thread_alt % 2 ) {
$classes[] = 'thread-odd'; $classes[] = 'thread-odd';
$classes[] = 'thread-alt'; $classes[] = 'thread-alt';
@ -814,9 +814,9 @@ function get_comment_link( $comment = null, $args = array() ) {
$cpage = $args['page']; $cpage = $args['page'];
if ( '' == $cpage ) { if ( '' === $cpage ) {
if ( ! empty( $in_comment_loop ) ) { if ( ! empty( $in_comment_loop ) ) {
$cpage = get_query_var( 'cpage' ); $cpage = (int) get_query_var( 'cpage' );
} else { } else {
// Requires a database hit, so we only do it when we can't figure out from context. // Requires a database hit, so we only do it when we can't figure out from context.
$cpage = get_page_of_comment( $comment->comment_ID, $args ); $cpage = get_page_of_comment( $comment->comment_ID, $args );
@ -1605,7 +1605,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false
$overridden_cpage = false; $overridden_cpage = false;
if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) { if ( '' === get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) {
set_query_var( 'cpage', 'newest' === get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 ); set_query_var( 'cpage', 'newest' === get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 );
$overridden_cpage = true; $overridden_cpage = true;
} }
@ -2291,13 +2291,13 @@ function wp_list_comments( $args = array(), $comments = null ) {
* perform a separate comment query and allow Walker_Comment to paginate. * perform a separate comment query and allow Walker_Comment to paginate.
*/ */
if ( $parsed_args['page'] || $parsed_args['per_page'] ) { if ( $parsed_args['page'] || $parsed_args['per_page'] ) {
$current_cpage = get_query_var( 'cpage' ); $current_cpage = (int) get_query_var( 'cpage' );
if ( ! $current_cpage ) { if ( ! $current_cpage ) {
$current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages; $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
} }
$current_per_page = get_query_var( 'comments_per_page' ); $current_per_page = (int) get_query_var( 'comments_per_page' );
if ( $parsed_args['page'] != $current_cpage || $parsed_args['per_page'] != $current_per_page ) { if ( (int) $parsed_args['page'] !== $current_cpage || (int) $parsed_args['per_page'] !== $current_per_page ) {
$comment_args = array( $comment_args = array(
'post_id' => get_the_ID(), 'post_id' => get_the_ID(),
'orderby' => 'comment_date_gmt', 'orderby' => 'comment_date_gmt',
@ -2348,15 +2348,15 @@ function wp_list_comments( $args = array(), $comments = null ) {
if ( $wp_query->max_num_comment_pages ) { if ( $wp_query->max_num_comment_pages ) {
$default_comments_page = get_option( 'default_comments_page' ); $default_comments_page = get_option( 'default_comments_page' );
$cpage = get_query_var( 'cpage' ); $cpage = (int) get_query_var( 'cpage' );
if ( 'newest' === $default_comments_page ) { if ( 'newest' === $default_comments_page ) {
$parsed_args['cpage'] = $cpage; $parsed_args['cpage'] = $cpage;
} elseif ( 1 === $cpage ) {
/* /*
* When first page shows oldest comments, post permalink is the same as * When the first page shows the oldest comments,
* the comment permalink. * post permalink is the same as the comment permalink.
*/ */
} elseif ( 1 == $cpage ) {
$parsed_args['cpage'] = ''; $parsed_args['cpage'] = '';
} else { } else {
$parsed_args['cpage'] = $cpage; $parsed_args['cpage'] = $cpage;
@ -2389,14 +2389,16 @@ function wp_list_comments( $args = array(), $comments = null ) {
if ( empty( $overridden_cpage ) ) { if ( empty( $overridden_cpage ) ) {
$parsed_args['page'] = get_query_var( 'cpage' ); $parsed_args['page'] = get_query_var( 'cpage' );
} else { } else {
$threaded = ( -1 != $parsed_args['max_depth'] ); $threaded = ( -1 !== (int) $parsed_args['max_depth'] );
$parsed_args['page'] = ( 'newest' === get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $parsed_args['per_page'], $threaded ) : 1; $parsed_args['page'] = ( 'newest' === get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $parsed_args['per_page'], $threaded ) : 1;
set_query_var( 'cpage', $parsed_args['page'] ); set_query_var( 'cpage', $parsed_args['page'] );
} }
} }
// Validation check. // Validation check.
$parsed_args['page'] = (int) $parsed_args['page']; $parsed_args['page'] = (int) $parsed_args['page'];
if ( 0 == $parsed_args['page'] && 0 != $parsed_args['per_page'] ) { $parsed_args['per_page'] = (int) $parsed_args['per_page'];
if ( 0 === $parsed_args['page'] && 0 !== $parsed_args['per_page'] ) {
$parsed_args['page'] = 1; $parsed_args['page'] = 1;
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.7-beta1-59182'; $wp_version = '6.7-beta1-59183';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.