From 17a4c20d55e15065547fd9d2cb41debca5bb41f0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 8 Sep 2020 13:41:08 +0000 Subject: [PATCH] Comments: Check if a valid comment ID was passed when editing a comment. This avoids a PHP notice after submitting the Edit Comment form. Props regan.khadgi. Fixes #51263. Built from https://develop.svn.wordpress.org/trunk@48958 git-svn-id: http://core.svn.wordpress.org/trunk@48720 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/comment.php | 18 +++++++++++------- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/wp-admin/comment.php b/wp-admin/comment.php index bdba4604a8..550045f9ec 100644 --- a/wp-admin/comment.php +++ b/wp-admin/comment.php @@ -36,14 +36,18 @@ if ( isset( $_GET['dt'] ) ) { } } -$comment_id = absint( $_GET['c'] ); -$comment = get_comment( $comment_id ); +if ( isset( $_REQUEST['c'] ) ) { + $comment_id = absint( $_REQUEST['c'] ); + $comment = get_comment( $comment_id ); -// Prevent actions on a comment associated with a trashed post. -if ( 'trash' === get_post_status( $comment->comment_post_ID ) ) { - wp_die( - __( 'You can’t edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' ) - ); + // Prevent actions on a comment associated with a trashed post. + if ( $comment && 'trash' === get_post_status( $comment->comment_post_ID ) ) { + wp_die( + __( 'You can’t edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' ) + ); + } +} else { + $comment = null; } switch ( $action ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index d8091b85f7..1466ce01a0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-48957'; +$wp_version = '5.6-alpha-48958'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.