Code Duplication    Length = 6-7 lines in 2 locations

src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 1 location

@@ 328-333 (lines=6) @@
325
			return $error;
326
		}
327
328
		if ( ! empty( $comment->comment_post_ID ) ) {
329
			$post = get_post( (int) $comment->comment_post_ID );
330
			if ( empty( $post ) ) {
331
				return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
332
			}
333
		}
334
335
		return $comment;
336
	}

src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1 location

@@ 1066-1072 (lines=7) @@
1063
		if ( ! empty( $schema['properties']['parent'] ) && isset( $request['parent'] ) ) {
1064
			if ( 0 === (int) $request['parent'] ) {
1065
				$prepared_post->post_parent = 0;
1066
			} else {
1067
				$parent = get_post( (int) $request['parent'] );
1068
				if ( empty( $parent ) ) {
1069
					return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent ID.' ), array( 'status' => 400 ) );
1070
				}
1071
				$prepared_post->post_parent = (int) $parent->ID;
1072
			}
1073
		}
1074
1075
		// Menu order.