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.
Built from https://develop.svn.wordpress.org/branches/5.5@48959


git-svn-id: http://core.svn.wordpress.org/branches/5.5@48721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-09-08 22:46:07 +00:00
parent a4b9563038
commit 2434d8188d
2 changed files with 12 additions and 8 deletions

View File

@ -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 ) {

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5.2-alpha-48956';
$wp_version = '5.5.2-alpha-48959';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.