From ee4f7d7415205869eb424cde6f6de1ebc80f91e0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 21 Jul 2022 10:59:10 +0000 Subject: [PATCH] Coding Standards: Adjust the logic slightly in `wp_ajax_replyto_comment()`. This aims to bring more consistency to the function logic by separating the comment content and type checks from the user existence check. Follow-up to [8720], [9098], [29758]. See #55647. Built from https://develop.svn.wordpress.org/trunk@53747 git-svn-id: http://core.svn.wordpress.org/trunk@53306 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 8 +++++--- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index ffb80e2369..49276b4bd0 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -1297,12 +1297,10 @@ function wp_ajax_replyto_comment( $action ) { $user = wp_get_current_user(); if ( $user->exists() ) { - $user_id = $user->ID; $comment_author = wp_slash( $user->display_name ); $comment_author_email = wp_slash( $user->user_email ); $comment_author_url = wp_slash( $user->user_url ); - $comment_content = trim( $_POST['content'] ); - $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : 'comment'; + $user_id = $user->ID; if ( current_user_can( 'unfiltered_html' ) ) { if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) { @@ -1320,10 +1318,14 @@ function wp_ajax_replyto_comment( $action ) { wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) ); } + $comment_content = trim( $_POST['content'] ); + if ( '' === $comment_content ) { wp_die( __( 'Please type your comment text.' ) ); } + $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : 'comment'; + $comment_parent = 0; if ( isset( $_POST['comment_ID'] ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index dcb9330dd9..6dd76bf6ca 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53746'; +$wp_version = '6.1-alpha-53747'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.