Code Duplication    Length = 21-24 lines in 2 locations

src/wp-includes/class-wp-xmlrpc-server.php 2 locations

@@ 3314-3337 (lines=24) @@
3311
	 * }
3312
	 * @return array|IXR_Error
3313
	 */
3314
	public function wp_getComment($args) {
3315
		$this->escape($args);
3316
3317
		$username	= $args[1];
3318
		$password	= $args[2];
3319
		$comment_id	= (int) $args[3];
3320
3321
		if ( ! $user = $this->login( $username, $password ) ) {
3322
			return $this->error;
3323
		}
3324
3325
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3326
		do_action( 'xmlrpc_call', 'wp.getComment' );
3327
3328
		if ( ! $comment = get_comment( $comment_id ) ) {
3329
			return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
3330
		}
3331
3332
		if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
3333
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
3334
		}
3335
3336
		return $this->_prepare_comment( $comment );
3337
	}
3338
3339
	/**
3340
	 * Retrieve comments.
@@ 4027-4047 (lines=21) @@
4024
	 *  - 'description'
4025
	 *  - 'metadata'
4026
	 */
4027
	public function wp_getMediaItem( $args ) {
4028
		$this->escape( $args );
4029
4030
		$username		= $args[1];
4031
		$password		= $args[2];
4032
		$attachment_id	= (int) $args[3];
4033
4034
		if ( !$user = $this->login($username, $password) )
4035
			return $this->error;
4036
4037
		if ( !current_user_can( 'upload_files' ) )
4038
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) );
4039
4040
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4041
		do_action( 'xmlrpc_call', 'wp.getMediaItem' );
4042
4043
		if ( ! $attachment = get_post($attachment_id) )
4044
			return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
4045
4046
		return $this->_prepare_media_item( $attachment );
4047
	}
4048
4049
	/**
4050
	 * Retrieves a collection of media library items (or attachments)