diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 6a27a67d92..63614663de 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -2324,13 +2324,14 @@ function wp_list_comments( $args = array(), $comments = null ) { function comment_form( $args = array(), $post = null ) { $post = get_post( $post ); - $post_id = $post ? $post->ID : get_the_ID(); - - // Exit the function when comments for the post are closed. - if ( ! comments_open( $post_id ) ) { + // Exit the function if the post is invalid or comments are closed. + if ( ! $post || ! comments_open( $post ) ) { /** * Fires after the comment form if comments are closed. * + * For backward compatibility, this action also fires if comment_form() + * is called with an invalid post object or ID. + * * @since 3.0.0 */ do_action( 'comment_form_comments_closed' ); @@ -2338,6 +2339,7 @@ function comment_form( $args = array(), $post = null ) { return; } + $post_id = $post->ID; $commenter = wp_get_current_commenter(); $user = wp_get_current_user(); $user_identity = $user->exists() ? $user->display_name : ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index 78acd1a287..7d4578969c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-beta3-54487'; +$wp_version = '6.1-beta3-54488'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.