From c87e26396b559173714491b222b4f0122a5ad653 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 8 Sep 2020 22:44:56 +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. Follow-up to [48050]. Props regan.khadgi. Merges [48958] to the 5.5 branch. Fixes #51263. git-svn-id: https://develop.svn.wordpress.org/branches/5.5@48959 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/comment.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/comment.php b/src/wp-admin/comment.php index bdba4604a8..550045f9ec 100644 --- a/src/wp-admin/comment.php +++ b/src/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 ) {