Index: src/wp-includes/class-wp-comment-query.php
===================================================================
--- src/wp-includes/class-wp-comment-query.php	(revision 43661)
+++ src/wp-includes/class-wp-comment-query.php	(working copy)
@@ -635,6 +635,7 @@
 		$number = absint( $this->query_vars['number'] );
 		$offset = absint( $this->query_vars['offset'] );
 		$paged  = absint( $this->query_vars['paged'] );
+		$limits = '';
 
 		if ( ! empty( $number ) ) {
 			if ( $offset ) {
@@ -819,7 +820,8 @@
 			$this->sql_clauses['where']['post_author__not_in'] = 'post_author NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__not_in'] ) ) . ' )';
 		}
 
-		$join = '';
+		$join    = '';
+		$groupby = '';
 
 		if ( $join_posts_table ) {
 			$join .= "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
Index: src/wp-includes/class-wp-xmlrpc-server.php
===================================================================
--- src/wp-includes/class-wp-xmlrpc-server.php	(revision 43661)
+++ src/wp-includes/class-wp-xmlrpc-server.php	(working copy)
@@ -3700,6 +3700,10 @@
 		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
 		do_action( 'xmlrpc_call', 'wp.editComment' );
 
+		$comment = array(
+			'comment_ID' => $comment_ID,
+		);
+
 		if ( isset( $content_struct['status'] ) ) {
 			$statuses = get_comment_statuses();
 			$statuses = array_keys( $statuses );
@@ -3707,36 +3711,33 @@
 			if ( ! in_array( $content_struct['status'], $statuses ) ) {
 				return new IXR_Error( 401, __( 'Invalid comment status.' ) );
 			}
-			$comment_approved = $content_struct['status'];
+			$comment['comment_approved'] = $content_struct['status'];
 		}
 
 		// Do some timestamp voodoo
 		if ( ! empty( $content_struct['date_created_gmt'] ) ) {
 			// We know this is supposed to be GMT, so we're going to slap that Z on there by force
-			$dateCreated      = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
-			$comment_date     = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) );
-			$comment_date_gmt = iso8601_to_datetime( $dateCreated, 'GMT' );
+			$dateCreated                 = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
+			$comment['comment_date']     = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) );
+			$comment['comment_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' );
 		}
 
 		if ( isset( $content_struct['content'] ) ) {
-			$comment_content = $content_struct['content'];
+			$comment['comment_content'] = $content_struct['content'];
 		}
 
 		if ( isset( $content_struct['author'] ) ) {
-			$comment_author = $content_struct['author'];
+			$comment['comment_author'] = $content_struct['author'];
 		}
 
 		if ( isset( $content_struct['author_url'] ) ) {
-			$comment_author_url = $content_struct['author_url'];
+			$comment['comment_author_url'] = $content_struct['author_url'];
 		}
 
 		if ( isset( $content_struct['author_email'] ) ) {
-			$comment_author_email = $content_struct['author_email'];
+			$comment['comment_author_email'] = $content_struct['author_email'];
 		}
 
-		// We've got all the data -- post it:
-		$comment = compact( 'comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url' );
-
 		$result = wp_update_comment( $comment );
 		if ( is_wp_error( $result ) ) {
 			return new IXR_Error( 500, $result->get_error_message() );
@@ -5261,16 +5262,22 @@
 		// Only use a password if one was given.
 		if ( isset( $content_struct['wp_password'] ) ) {
 			$post_password = $content_struct['wp_password'];
+		} else {
+			$post_password = '';
 		}
 
 		// Only set a post parent if one was provided.
 		if ( isset( $content_struct['wp_page_parent_id'] ) ) {
 			$post_parent = $content_struct['wp_page_parent_id'];
+		} else {
+			$post_parent = 0;
 		}
 
 		// Only set the menu_order if it was provided.
 		if ( isset( $content_struct['wp_page_order'] ) ) {
 			$menu_order = $content_struct['wp_page_order'];
+		} else {
+			$menu_order = 0;
 		}
 
 		$post_author = $user->ID;
@@ -5599,14 +5606,16 @@
 
 		$this->escape( $postdata );
 
-		$ID            = $postdata['ID'];
-		$post_content  = $postdata['post_content'];
-		$post_title    = $postdata['post_title'];
-		$post_excerpt  = $postdata['post_excerpt'];
-		$post_password = $postdata['post_password'];
-		$post_parent   = $postdata['post_parent'];
-		$post_type     = $postdata['post_type'];
-		$menu_order    = $postdata['menu_order'];
+		$ID             = $postdata['ID'];
+		$post_content   = $postdata['post_content'];
+		$post_title     = $postdata['post_title'];
+		$post_excerpt   = $postdata['post_excerpt'];
+		$post_password  = $postdata['post_password'];
+		$post_parent    = $postdata['post_parent'];
+		$post_type      = $postdata['post_type'];
+		$menu_order     = $postdata['menu_order'];
+		$ping_status    = $postdata['ping_status'];
+		$comment_status = $postdata['comment_status'];
 
 		// Let WordPress manage slug if none was provided.
 		$post_name = $postdata['post_name'];
Index: src/wp-includes/comment.php
===================================================================
--- src/wp-includes/comment.php	(revision 43661)
+++ src/wp-includes/comment.php	(working copy)
@@ -3094,7 +3094,7 @@
  */
 function wp_handle_comment_submission( $comment_data ) {
 
-	$comment_post_ID = $comment_parent = 0;
+	$comment_post_ID = $comment_parent = $user_ID = 0;
 	$comment_author  = $comment_author_email = $comment_author_url = $comment_content = null;
 
 	if ( isset( $comment_data['comment_post_ID'] ) ) {
Index: src/wp-includes/post.php
===================================================================
--- src/wp-includes/post.php	(revision 43661)
+++ src/wp-includes/post.php	(working copy)
@@ -3345,19 +3345,17 @@
 
 	unset( $postarr['filter'] );
 
-	$postarr = sanitize_post( $postarr, 'db' );
+	$postarr           = sanitize_post( $postarr, 'db' );
+	$sanitized_postarr = $postarr;
 
 	// Are we updating or creating?
-	$post_ID = 0;
-	$update  = false;
-	$guid    = $postarr['guid'];
+	$update = false;
 
 	if ( ! empty( $postarr['ID'] ) ) {
 		$update = true;
 
 		// Get the post ID and GUID.
-		$post_ID     = $postarr['ID'];
-		$post_before = get_post( $post_ID );
+		$post_before = get_post( $postarr['ID'] );
 		if ( is_null( $post_before ) ) {
 			if ( $wp_error ) {
 				return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
@@ -3365,29 +3363,26 @@
 			return 0;
 		}
 
-		$guid            = get_post_field( 'guid', $post_ID );
-		$previous_status = get_post_field( 'post_status', $post_ID );
+		$postarr['guid'] = get_post_field( 'guid', $postarr['ID'] );
+		$previous_status = get_post_field( 'post_status', $postarr['ID'] );
 	} else {
 		$previous_status = 'new';
 	}
 
-	$post_type = empty( $postarr['post_type'] ) ? 'post' : $postarr['post_type'];
+	if ( empty( $postarr['post_type'] ) ) {
+		$postarr['post_type'] = 'post';
+	}
 
-	$post_title   = $postarr['post_title'];
-	$post_content = $postarr['post_content'];
-	$post_excerpt = $postarr['post_excerpt'];
-	if ( isset( $postarr['post_name'] ) ) {
-		$post_name = $postarr['post_name'];
-	} elseif ( $update ) {
+	if ( ! isset( $postarr['post_name'] ) && $update ) {
 		// For an update, don't modify the post_name if it wasn't supplied as an argument.
-		$post_name = $post_before->post_name;
+		$postarr['post_name'] = $post_before->post_name;
 	}
 
-	$maybe_empty = 'attachment' !== $post_type
-		&& ! $post_content && ! $post_title && ! $post_excerpt
-		&& post_type_supports( $post_type, 'editor' )
-		&& post_type_supports( $post_type, 'title' )
-		&& post_type_supports( $post_type, 'excerpt' );
+	$maybe_empty = 'attachment' !== $postarr['post_type']
+		&& ! $postarr['post_content'] && ! $postarr['post_title'] && ! $postarr['post_excerpt']
+		&& post_type_supports( $postarr['post_type'], 'editor' )
+		&& post_type_supports( $postarr['post_type'], 'title' )
+		&& post_type_supports( $postarr['post_type'], 'excerpt' );
 
 	/**
 	 * Filters whether the post should be considered "empty".
@@ -3413,23 +3408,26 @@
 		}
 	}
 
-	$post_status = empty( $postarr['post_status'] ) ? 'draft' : $postarr['post_status'];
-	if ( 'attachment' === $post_type && ! in_array( $post_status, array( 'inherit', 'private', 'trash', 'auto-draft' ), true ) ) {
-		$post_status = 'inherit';
+	if ( empty( $postarr['post_status'] ) ) {
+		$postarr['post_status'] = 'draft';
 	}
 
+	if ( 'attachment' === $postarr['post_type'] && ! in_array( $postarr['post_status'], array( 'inherit', 'private', 'trash', 'auto-draft' ), true ) ) {
+		$postarr['post_status'] = 'inherit';
+	}
+
 	if ( ! empty( $postarr['post_category'] ) ) {
 		// Filter out empty terms.
-		$post_category = array_filter( $postarr['post_category'] );
+		$postarr['post_category'] = array_filter( $postarr['post_category'] );
 	}
 
 	// Make sure we set a valid category.
-	if ( empty( $post_category ) || 0 == count( $post_category ) || ! is_array( $post_category ) ) {
+	if ( empty( $postarr['post_category'] ) || 0 == count( $postarr['post_category'] ) || ! is_array( $postarr['post_category'] ) ) {
 		// 'post' requires at least one category.
-		if ( 'post' == $post_type && 'auto-draft' != $post_status ) {
-			$post_category = array( get_option( 'default_category' ) );
+		if ( 'post' == $postarr['post_type'] && 'auto-draft' != $postarr['post_status'] ) {
+			$postarr['post_category'] = array( get_option( 'default_category' ) );
 		} else {
-			$post_category = array();
+			$postarr['post_category'] = array();
 		}
 	}
 
@@ -3438,12 +3436,12 @@
 	 *
 	 * For new posts check the primitive capability, for updates check the meta capability.
 	 */
-	$post_type_object = get_post_type_object( $post_type );
+	$post_type_object = get_post_type_object( $postarr['post_type'] );
 
-	if ( ! $update && 'pending' === $post_status && ! current_user_can( $post_type_object->cap->publish_posts ) ) {
-		$post_name = '';
-	} elseif ( $update && 'pending' === $post_status && ! current_user_can( 'publish_post', $post_ID ) ) {
-		$post_name = '';
+	if ( ! $update && 'pending' === $postarr['post_status'] && ! current_user_can( $post_type_object->cap->publish_posts ) ) {
+		$postarr['post_name'] = '';
+	} elseif ( $update && 'pending' === $postarr['post_status'] && ! current_user_can( 'publish_post', $postarr['ID'] ) ) {
+		$postarr['post_name'] = '';
 	}
 
 	/*
@@ -3450,19 +3448,19 @@
 	 * Create a valid post name. Drafts and pending posts are allowed to have
 	 * an empty post name.
 	 */
-	if ( empty( $post_name ) ) {
-		if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
-			$post_name = sanitize_title( $post_title );
+	if ( empty( $postarr['post_name'] ) ) {
+		if ( ! in_array( $postarr['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
+			$postarr['post_name'] = sanitize_title( $postarr['post_title'] );
 		} else {
-			$post_name = '';
+			$postarr['post_name'] = '';
 		}
 	} else {
 		// On updates, we need to check to see if it's using the old, fixed sanitization context.
-		$check_name = sanitize_title( $post_name, '', 'old-save' );
-		if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_ID ) == $check_name ) {
-			$post_name = $check_name;
+		$check_name = sanitize_title( $postarr['post_name'], '', 'old-save' );
+		if ( $update && strtolower( urlencode( $postarr['post_name'] ) ) == $check_name && get_post_field( 'post_name', $postarr['ID'] ) == $check_name ) {
+			$postarr['post_name'] = $check_name;
 		} else { // new post, or slug has changed.
-			$post_name = sanitize_title( $post_name );
+			$postarr['post_name'] = sanitize_title( $postarr['post_name'] );
 		}
 	}
 
@@ -3472,19 +3470,17 @@
 	 */
 	if ( empty( $postarr['post_date'] ) || '0000-00-00 00:00:00' == $postarr['post_date'] ) {
 		if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
-			$post_date = current_time( 'mysql' );
+			$postarr['post_date'] = current_time( 'mysql' );
 		} else {
-			$post_date = get_date_from_gmt( $postarr['post_date_gmt'] );
+			$postarr['post_date'] = get_date_from_gmt( $postarr['post_date_gmt'] );
 		}
-	} else {
-		$post_date = $postarr['post_date'];
 	}
 
 	// Validate the date.
-	$mm         = substr( $post_date, 5, 2 );
-	$jj         = substr( $post_date, 8, 2 );
-	$aa         = substr( $post_date, 0, 4 );
-	$valid_date = wp_checkdate( $mm, $jj, $aa, $post_date );
+	$mm         = substr( $postarr['post_date'], 5, 2 );
+	$jj         = substr( $postarr['post_date'], 8, 2 );
+	$aa         = substr( $postarr['post_date'], 0, 4 );
+	$valid_date = wp_checkdate( $mm, $jj, $aa, $postarr['post_date'] );
 	if ( ! $valid_date ) {
 		if ( $wp_error ) {
 			return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
@@ -3494,33 +3490,31 @@
 	}
 
 	if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
-		if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
-			$post_date_gmt = get_gmt_from_date( $post_date );
+		if ( ! in_array( $postarr['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
+			$postarr['post_date_gmt'] = get_gmt_from_date( $postarr['post_date'] );
 		} else {
-			$post_date_gmt = '0000-00-00 00:00:00';
+			$postarr['post_date_gmt'] = '0000-00-00 00:00:00';
 		}
-	} else {
-		$post_date_gmt = $postarr['post_date_gmt'];
 	}
 
-	if ( $update || '0000-00-00 00:00:00' == $post_date ) {
-		$post_modified     = current_time( 'mysql' );
-		$post_modified_gmt = current_time( 'mysql', 1 );
+	if ( $update || '0000-00-00 00:00:00' == $postarr['post_date'] ) {
+		$postarr['post_modified']     = current_time( 'mysql' );
+		$postarr['post_modified_gmt'] = current_time( 'mysql', 1 );
 	} else {
-		$post_modified     = $post_date;
-		$post_modified_gmt = $post_date_gmt;
+		$postarr['post_modified']     = $postarr['post_date'];
+		$postarr['post_modified_gmt'] = $postarr['post_date_gmt'];
 	}
 
-	if ( 'attachment' !== $post_type ) {
-		if ( 'publish' == $post_status ) {
+	if ( 'attachment' !== $postarr['post_type'] ) {
+		if ( 'publish' == $postarr['post_status'] ) {
 			$now = gmdate( 'Y-m-d H:i:59' );
-			if ( mysql2date( 'U', $post_date_gmt, false ) > mysql2date( 'U', $now, false ) ) {
-				$post_status = 'future';
+			if ( mysql2date( 'U', $postarr['post_date_gmt'], false ) > mysql2date( 'U', $now, false ) ) {
+				$postarr['post_status'] = 'future';
 			}
-		} elseif ( 'future' == $post_status ) {
+		} elseif ( 'future' == $postarr['post_status'] ) {
 			$now = gmdate( 'Y-m-d H:i:59' );
-			if ( mysql2date( 'U', $post_date_gmt, false ) <= mysql2date( 'U', $now, false ) ) {
-				$post_status = 'publish';
+			if ( mysql2date( 'U', $postarr['post_date_gmt'], false ) <= mysql2date( 'U', $now, false ) ) {
+				$postarr['post_status'] = 'publish';
 			}
 		}
 	}
@@ -3528,41 +3522,44 @@
 	// Comment status.
 	if ( empty( $postarr['comment_status'] ) ) {
 		if ( $update ) {
-			$comment_status = 'closed';
+			$postarr['comment_status'] = 'closed';
 		} else {
-			$comment_status = get_default_comment_status( $post_type );
+			$postarr['comment_status'] = get_default_comment_status( $postarr['post_type'] );
 		}
+	}
+
+	if ( ! isset( $postarr['post_author'] ) ) {
+		$postarr['post_author'] = $user_id;
+	}
+
+	if ( empty( $postarr['ping_status'] ) ) {
+		$postarr['ping_status'] = get_default_comment_status( $postarr['post_type'], 'pingback' );
+	}
+
+	if ( isset( $postarr['to_ping'] ) ) {
+		$postarr['to_ping'] = sanitize_trackback_urls( $postarr['to_ping'] );
 	} else {
-		$comment_status = $postarr['comment_status'];
+		$postarr['to_ping'];
 	}
 
-	// These variables are needed by compact() later.
-	$post_content_filtered = $postarr['post_content_filtered'];
-	$post_author           = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id;
-	$ping_status           = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status'];
-	$to_ping               = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : '';
-	$pinged                = isset( $postarr['pinged'] ) ? $postarr['pinged'] : '';
-	$import_id             = isset( $postarr['import_id'] ) ? $postarr['import_id'] : 0;
-
 	/*
 	 * The 'wp_insert_post_parent' filter expects all variables to be present.
 	 * Previously, these variables would have already been extracted
 	 */
 	if ( isset( $postarr['menu_order'] ) ) {
-		$menu_order = (int) $postarr['menu_order'];
+		$postarr['menu_order'] = (int) $postarr['menu_order'];
 	} else {
-		$menu_order = 0;
+		$postarr['menu_order'] = 0;
 	}
 
-	$post_password = isset( $postarr['post_password'] ) ? $postarr['post_password'] : '';
-	if ( 'private' == $post_status ) {
-		$post_password = '';
+	if ( 'private' == $postarr['post_status'] ) {
+		$postarr['post_password'] = '';
 	}
 
 	if ( isset( $postarr['post_parent'] ) ) {
-		$post_parent = (int) $postarr['post_parent'];
+		$postarr['post_parent'] = (int) $postarr['post_parent'];
 	} else {
-		$post_parent = 0;
+		$postarr['post_parent'] = 0;
 	}
 
 	/**
@@ -3570,42 +3567,69 @@
 	 *
 	 * @since 3.1.0
 	 *
-	 * @param int   $post_parent Post parent ID.
-	 * @param int   $post_ID     Post ID.
-	 * @param array $new_postarr Array of parsed post data.
-	 * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
+	 * @param int   $post_parent       Post parent ID.
+	 * @param int   $post_ID           Post ID.
+	 * @param array $postarr           Array of parsed post data.
+	 * @param array $sanitized_postarr Array of sanitized, but otherwise unmodified post data.
 	 */
-	$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
+	$postarr['post_parent'] = apply_filters( 'wp_insert_post_parent', $postarr['post_parent'], $postarr['ID'], $postarr, $sanitized_postarr );
 
 	/*
 	 * If the post is being untrashed and it has a desired slug stored in post meta,
 	 * reassign it.
 	 */
-	if ( 'trash' === $previous_status && 'trash' !== $post_status ) {
-		$desired_post_slug = get_post_meta( $post_ID, '_wp_desired_post_slug', true );
+	if ( 'trash' === $previous_status && 'trash' !== $postarr['post_status'] ) {
+		$desired_post_slug = get_post_meta( $postarr['ID'], '_wp_desired_post_slug', true );
 		if ( $desired_post_slug ) {
-			delete_post_meta( $post_ID, '_wp_desired_post_slug' );
-			$post_name = $desired_post_slug;
+			delete_post_meta( $postarr['ID'], '_wp_desired_post_slug' );
+			$postarr['post_name'] = $desired_post_slug;
 		}
 	}
 
 	// If a trashed post has the desired slug, change it and let this post have it.
-	if ( 'trash' !== $post_status && $post_name ) {
-		wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID );
+	if ( 'trash' !== $postarr['post_status'] && $postarr['post_name'] ) {
+		wp_add_trashed_suffix_to_post_name_for_trashed_posts( $postarr['post_name'], $postarr['ID'] );
 	}
 
 	// When trashing an existing post, change its slug to allow non-trashed posts to use it.
-	if ( 'trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status ) {
-		$post_name = wp_add_trashed_suffix_to_post_name_for_post( $post_ID );
+	if ( 'trash' === $postarr['post_status'] && 'trash' !== $previous_status && 'new' !== $previous_status ) {
+		$postarr['post_name'] = wp_add_trashed_suffix_to_post_name_for_post( $postarr['ID'] );
 	}
 
-	$post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent );
+	$postarr['post_name'] = wp_unique_post_slug( $postarr['post_name'], $postarr['ID'], $postarr['post_status'], $postarr['post_type'], $postarr['post_parent'] );
 
 	// Don't unslash.
-	$post_mime_type = isset( $postarr['post_mime_type'] ) ? $postarr['post_mime_type'] : '';
+	if ( ! isset( $postarr['post_mime_type'] ) ) {
+		$postarr['post_mime_type'] = '';
+	}
 
 	// Expected_slashed (everything!).
-	$data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' );
+	$data = wp_array_slice_assoc(
+		$postarr,
+		array(
+			'post_author',
+			'post_date',
+			'post_date_gmt',
+			'post_content',
+			'post_content_filtered',
+			'post_title',
+			'post_excerpt',
+			'post_status',
+			'post_type',
+			'comment_status',
+			'ping_status',
+			'post_password',
+			'post_name',
+			'to_ping',
+			'pinged',
+			'post_modified',
+			'post_modified_gmt',
+			'post_parent',
+			'menu_order',
+			'post_mime_type',
+			'guid',
+		)
+	);
 
 	$emoji_fields = array( 'post_title', 'post_content', 'post_excerpt' );
 
@@ -3618,16 +3642,16 @@
 		}
 	}
 
-	if ( 'attachment' === $post_type ) {
+	if ( 'attachment' === $postarr['post_type'] ) {
 		/**
 		 * Filters attachment post data before it is updated in or added to the database.
 		 *
 		 * @since 3.9.0
 		 *
-		 * @param array $data    An array of sanitized attachment post data.
-		 * @param array $postarr An array of unsanitized attachment post data.
+		 * @param array $data              An array of sanitized attachment post data.
+		 * @param array $sanitized_postarr An array of unsanitized attachment post data.
 		 */
-		$data = apply_filters( 'wp_insert_attachment_data', $data, $postarr );
+		$data = apply_filters( 'wp_insert_attachment_data', $data, $sanitized_postarr );
 	} else {
 		/**
 		 * Filters slashed post data just before it is inserted into the database.
@@ -3634,13 +3658,13 @@
 		 *
 		 * @since 2.7.0
 		 *
-		 * @param array $data    An array of slashed post data.
-		 * @param array $postarr An array of sanitized, but otherwise unmodified post data.
+		 * @param array $data              An array of slashed post data.
+		 * @param array $sanitized_postarr An array of sanitized, but otherwise unmodified post data.
 		 */
-		$data = apply_filters( 'wp_insert_post_data', $data, $postarr );
+		$data = apply_filters( 'wp_insert_post_data', $data, $sanitized_postarr );
 	}
 	$data  = wp_unslash( $data );
-	$where = array( 'ID' => $post_ID );
+	$where = array( 'ID' => $postarr['ID'] );
 
 	if ( $update ) {
 		/**
@@ -3651,7 +3675,7 @@
 		 * @param int   $post_ID Post ID.
 		 * @param array $data    Array of unslashed post data.
 		 */
-		do_action( 'pre_post_update', $post_ID, $data );
+		do_action( 'pre_post_update', $postarr['ID'], $data );
 		if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
 			if ( $wp_error ) {
 				return new WP_Error( 'db_update_error', __( 'Could not update post in the database' ), $wpdb->last_error );
@@ -3661,10 +3685,10 @@
 		}
 	} else {
 		// If there is a suggested ID, use it if not already present.
-		if ( ! empty( $import_id ) ) {
-			$import_id = (int) $import_id;
-			if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id ) ) ) {
-				$data['ID'] = $import_id;
+		if ( ! empty( $postarr['import_id'] ) ) {
+			$postarr['import_id'] = (int) $postarr['import_id'];
+			if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE ID = %d", $postarr['import_id'] ) ) ) {
+				$data['ID'] = $postarr['import_id'];
 			}
 		}
 		if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
@@ -3674,24 +3698,24 @@
 				return 0;
 			}
 		}
-		$post_ID = (int) $wpdb->insert_id;
+		$postarr['ID'] = (int) $wpdb->insert_id;
 
-		// Use the newly generated $post_ID.
-		$where = array( 'ID' => $post_ID );
+		// Use the newly generated $postarr['ID'].
+		$where = array( 'ID' => $postarr['ID'] );
 	}
 
 	if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
-		$data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent );
+		$data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $postarr['ID'] ), $postarr['ID'], $data['post_status'], $postarr['post_type'], $postarr['post_parent'] );
 		$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
-		clean_post_cache( $post_ID );
+		clean_post_cache( $postarr['ID'] );
 	}
 
-	if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
-		wp_set_post_categories( $post_ID, $post_category );
+	if ( is_object_in_taxonomy( $postarr['post_type'], 'category' ) ) {
+		wp_set_post_categories( $postarr['ID'], $postarr['post_category'] );
 	}
 
-	if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $post_type, 'post_tag' ) ) {
-		wp_set_post_tags( $post_ID, $postarr['tags_input'] );
+	if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $postarr['post_type'], 'post_tag' ) ) {
+		wp_set_post_tags( $postarr['ID'], $postarr['tags_input'] );
 	}
 
 	// New-style support for all custom taxonomies.
@@ -3709,7 +3733,7 @@
 				$tags = array_filter( $tags );
 			}
 			if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
-				wp_set_post_terms( $post_ID, $tags, $taxonomy );
+				wp_set_post_terms( $postarr['ID'], $tags, $taxonomy );
 			}
 		}
 	}
@@ -3716,34 +3740,34 @@
 
 	if ( ! empty( $postarr['meta_input'] ) ) {
 		foreach ( $postarr['meta_input'] as $field => $value ) {
-			update_post_meta( $post_ID, $field, $value );
+			update_post_meta( $postarr['ID'], $field, $value );
 		}
 	}
 
-	$current_guid = get_post_field( 'guid', $post_ID );
+	$current_guid = get_post_field( 'guid', $postarr['ID'] );
 
 	// Set GUID.
 	if ( ! $update && '' == $current_guid ) {
-		$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
+		$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $postarr['ID'] ) ), $where );
 	}
 
 	if ( 'attachment' === $postarr['post_type'] ) {
 		if ( ! empty( $postarr['file'] ) ) {
-			update_attached_file( $post_ID, $postarr['file'] );
+			update_attached_file( $postarr['ID'], $postarr['file'] );
 		}
 
 		if ( ! empty( $postarr['context'] ) ) {
-			add_post_meta( $post_ID, '_wp_attachment_context', $postarr['context'], true );
+			add_post_meta( $postarr['ID'], '_wp_attachment_context', $postarr['context'], true );
 		}
 	}
 
 	// Set or remove featured image.
 	if ( isset( $postarr['_thumbnail_id'] ) ) {
-		$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ) || 'revision' === $post_type;
-		if ( ! $thumbnail_support && 'attachment' === $post_type && $post_mime_type ) {
-			if ( wp_attachment_is( 'audio', $post_ID ) ) {
+		$thumbnail_support = current_theme_supports( 'post-thumbnails', $postarr['post_type'] ) && post_type_supports( $postarr['post_type'], 'thumbnail' ) || 'revision' === $postarr['post_type'];
+		if ( ! $thumbnail_support && 'attachment' === $postarr['post_type'] && $postarr['post_mime_type'] ) {
+			if ( wp_attachment_is( 'audio', $postarr['ID'] ) ) {
 				$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
-			} elseif ( wp_attachment_is( 'video', $post_ID ) ) {
+			} elseif ( wp_attachment_is( 'video', $postarr['ID'] ) ) {
 				$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
 			}
 		}
@@ -3751,16 +3775,16 @@
 		if ( $thumbnail_support ) {
 			$thumbnail_id = intval( $postarr['_thumbnail_id'] );
 			if ( -1 === $thumbnail_id ) {
-				delete_post_thumbnail( $post_ID );
+				delete_post_thumbnail( $postarr['ID'] );
 			} else {
-				set_post_thumbnail( $post_ID, $thumbnail_id );
+				set_post_thumbnail( $postarr['ID'], $thumbnail_id );
 			}
 		}
 	}
 
-	clean_post_cache( $post_ID );
+	clean_post_cache( $postarr['ID'] );
 
-	$post = get_post( $post_ID );
+	$post = get_post( $postarr['ID'] );
 
 	if ( ! empty( $postarr['page_template'] ) ) {
 		$post->page_template = $postarr['page_template'];
@@ -3769,9 +3793,9 @@
 			if ( $wp_error ) {
 				return new WP_Error( 'invalid_page_template', __( 'Invalid page template.' ) );
 			}
-			update_post_meta( $post_ID, '_wp_page_template', 'default' );
+			update_post_meta( $postarr['ID'], '_wp_page_template', 'default' );
 		} else {
-			update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
+			update_post_meta( $postarr['ID'], '_wp_page_template', $postarr['page_template'] );
 		}
 	}
 
@@ -3786,8 +3810,8 @@
 			 *
 			 * @param int $post_ID Attachment ID.
 			 */
-			do_action( 'edit_attachment', $post_ID );
-			$post_after = get_post( $post_ID );
+			do_action( 'edit_attachment', $postarr['ID'] );
+			$post_after = get_post( $postarr['ID'] );
 
 			/**
 			 * Fires once an existing attachment has been updated.
@@ -3798,7 +3822,7 @@
 			 * @param WP_Post $post_after   Post object following the update.
 			 * @param WP_Post $post_before  Post object before the update.
 			 */
-			do_action( 'attachment_updated', $post_ID, $post_after, $post_before );
+			do_action( 'attachment_updated', $postarr['ID'], $post_after, $post_before );
 		} else {
 
 			/**
@@ -3808,10 +3832,10 @@
 			 *
 			 * @param int $post_ID Attachment ID.
 			 */
-			do_action( 'add_attachment', $post_ID );
+			do_action( 'add_attachment', $postarr['ID'] );
 		}
 
-		return $post_ID;
+		return $postarr['ID'];
 	}
 
 	if ( $update ) {
@@ -3826,7 +3850,7 @@
 		 * @param int     $post_ID Post ID.
 		 * @param WP_Post $post    Post object.
 		 */
-		do_action( "edit_post_{$post->post_type}", $post_ID, $post );
+		do_action( "edit_post_{$post->post_type}", $postarr['ID'], $post );
 
 		/**
 		 * Fires once an existing post has been updated.
@@ -3836,9 +3860,9 @@
 		 * @param int     $post_ID Post ID.
 		 * @param WP_Post $post    Post object.
 		 */
-		do_action( 'edit_post', $post_ID, $post );
+		do_action( 'edit_post', $postarr['ID'], $post );
 
-		$post_after = get_post( $post_ID );
+		$post_after = get_post( $postarr['ID'] );
 
 		/**
 		 * Fires once an existing post has been updated.
@@ -3849,7 +3873,7 @@
 		 * @param WP_Post $post_after   Post object following the update.
 		 * @param WP_Post $post_before  Post object before the update.
 		 */
-		do_action( 'post_updated', $post_ID, $post_after, $post_before );
+		do_action( 'post_updated', $postarr['ID'], $post_after, $post_before );
 	}
 
 	/**
@@ -3864,7 +3888,7 @@
 	 * @param WP_Post $post    Post object.
 	 * @param bool    $update  Whether this is an existing post being updated or not.
 	 */
-	do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
+	do_action( "save_post_{$post->post_type}", $postarr['ID'], $post, $update );
 
 	/**
 	 * Fires once a post has been saved.
@@ -3875,7 +3899,7 @@
 	 * @param WP_Post $post    Post object.
 	 * @param bool    $update  Whether this is an existing post being updated or not.
 	 */
-	do_action( 'save_post', $post_ID, $post, $update );
+	do_action( 'save_post', $postarr['ID'], $post, $update );
 
 	/**
 	 * Fires once a post has been saved.
@@ -3886,9 +3910,9 @@
 	 * @param WP_Post $post    Post object.
 	 * @param bool    $update  Whether this is an existing post being updated or not.
 	 */
-	do_action( 'wp_insert_post', $post_ID, $post, $update );
+	do_action( 'wp_insert_post', $postarr['ID'], $post, $update );
 
-	return $post_ID;
+	return $postarr['ID'];
 }
 
 /**
Index: tests/phpunit/tests/dependencies/scripts.php
===================================================================
--- tests/phpunit/tests/dependencies/scripts.php	(revision 43661)
+++ tests/phpunit/tests/dependencies/scripts.php	(working copy)
@@ -866,6 +866,7 @@
 	 * @covers ::wp_enqueue_code_editor()
 	 */
 	public function test_wp_enqueue_code_editor_when_generated_array_by_compact_will_be_passed() {
+		$file                   = '';
 		$wp_enqueue_code_editor = wp_enqueue_code_editor( compact( 'file' ) );
 		$this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor );
 
