Code Duplication    Length = 8-9 lines in 2 locations

includes/abstracts/abstract-wc-rest-posts-controller.php 2 locations

@@ 186-194 (lines=9) @@
183
		$post->post_type = $this->post_type;
184
		$post_id         = wp_insert_post( $post, true );
185
186
		if ( is_wp_error( $post_id ) ) {
187
188
			if ( in_array( $post_id->get_error_code(), array( 'db_insert_error' ) ) ) {
189
				$post_id->add_data( array( 'status' => 500 ) );
190
			} else {
191
				$post_id->add_data( array( 'status' => 400 ) );
192
			}
193
			return $post_id;
194
		}
195
		$post->ID = $post_id;
196
		$post     = get_post( $post_id );
197
@@ 269-276 (lines=8) @@
266
		}
267
		// Convert the post object to an array, otherwise wp_update_post will expect non-escaped input.
268
		$post_id = wp_update_post( (array) $post, true );
269
		if ( is_wp_error( $post_id ) ) {
270
			if ( in_array( $post_id->get_error_code(), array( 'db_update_error' ) ) ) {
271
				$post_id->add_data( array( 'status' => 500 ) );
272
			} else {
273
				$post_id->add_data( array( 'status' => 400 ) );
274
			}
275
			return $post_id;
276
		}
277
278
		$post = get_post( $post_id );
279
		$this->update_additional_fields_for_object( $post, $request );