Commit 24c3566722 for wordpress.org

commit 24c3566722fd2f3957f0bd2af12cc685cbe01f8f
Author: SergeyBiryukov <sergeybiryukov@git.wordpress.org>
Date:   Sun Nov 15 20:17:56 2026 +0000

    Code Modernization: Use the null coalescing assignment operator in `wp-includes/comment.php`.

    Replaces verbose `! isset()` guard blocks that assign default values with the null coalescing assignment operator (`??=`).

    **Scope**

    This covers `get_comment_pages_count()` and `wp_new_comment()` completely.

    **Why this is safe**

    - `??=` requires PHP 7.4, which is already the minimum supported version.
    - `??=` and `! isset()` test the same condition, so the default is applied in exactly the same cases.
    - Assignment order is preserved.
    - No behavior change; this is a purely internal syntax simplification.

    Props noruzzaman, masteradhoc.
    See #65823.
    Built from https://develop.svn.wordpress.org/trunk@65530


    git-svn-id: http://core.svn.wordpress.org/trunk@64603 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index b6847266eb..cd622cbf0f 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -1074,19 +1074,17 @@ function get_comment_pages_count( $comments = null, $per_page = null, $threaded
 		return 1;
 	}

-	if ( ! isset( $per_page ) ) {
-		$per_page = (int) get_query_var( 'comments_per_page' );
-	}
+	$per_page ??= (int) get_query_var( 'comments_per_page' );
+
 	if ( 0 === $per_page ) {
 		$per_page = (int) get_option( 'comments_per_page' );
 	}
+
 	if ( 0 === $per_page ) {
 		return 1;
 	}

-	if ( ! isset( $threaded ) ) {
-		$threaded = get_option( 'thread_comments' );
-	}
+	$threaded ??= get_option( 'thread_comments' );

 	if ( $threaded ) {
 		$walker = new Walker_Comment();
@@ -2497,13 +2495,8 @@ function wp_new_comment( $commentdata, $wp_error = false ) {

 	$prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0;

-	if ( ! isset( $commentdata['comment_author_IP'] ) ) {
-		$commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
-	}
-
-	if ( ! isset( $commentdata['comment_agent'] ) ) {
-		$commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'] ?? '';
-	}
+	$commentdata['comment_author_IP'] ??= $_SERVER['REMOTE_ADDR'];
+	$commentdata['comment_agent']     ??= $_SERVER['HTTP_USER_AGENT'] ?? '';

 	/**
 	 * Filters a comment's data before it is sanitized and inserted into the database.
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 5e5a6ca522..7e23a2b621 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-beta5-65529';
+$wp_version = '7.2-beta5-65530';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.