Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Return WP_Error in get_comment for invalid comments - resolves #166 #171

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/class-wp-json-posts.php
Expand Up @@ -393,6 +393,10 @@ public function get_comments( $id ) {
*/ */
public function get_comment( $comment ) { public function get_comment( $comment ) {
$comment = get_comment( $comment ); $comment = get_comment( $comment );
if ( empty( $comment ) ) {
return new WP_Error( 'json_comment_invalid_id', __( 'Invalid comment ID.' ), array( 'status' => 404 ) );
}

$data = $this->prepare_comment( $comment ); $data = $this->prepare_comment( $comment );
return $data; return $data;
} }
Expand Down