Index: src/wp-includes/comment.php
===================================================================
--- src/wp-includes/comment.php	(revision 37426)
+++ src/wp-includes/comment.php	(working copy)
@@ -2263,22 +2263,24 @@
 	global $wpdb;
 
 	// Do pingbacks
-	while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
-		delete_metadata_by_mid( 'post', $ping->meta_id );
+	$pings = get_posts( array( 'post_type' => 'any', 'posts_per_page' => -1, 'meta_value' => '_pingme', 'fields' => 'ids' ) );
+	foreach ( $pings as $ping ) {
+		delete_post_meta( $ping->ID, '_pingme' );
 		pingback( $ping->post_content, $ping->ID );
 	}
 
 	// Do Enclosures
-	while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
-		delete_metadata_by_mid( 'post', $enclosure->meta_id );
+	$enclosures = get_posts( array( 'post_type' => 'any', 'posts_per_page' => -1, 'meta_value' => '_encloseme', 'fields' => 'ids' ) );
+	foreach ( $enclosures as $enclosure ) {
+		delete_post_meta( $enclosure->ID, '_encloseme' );
 		do_enclose( $enclosure->post_content, $enclosure->ID );
 	}
 
 	// Do Trackbacks
-	$trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'");
-	if ( is_array($trackbacks) )
-		foreach ( $trackbacks as $trackback )
-			do_trackbacks($trackback);
+	$trackbacks = get_posts( array( 'post_type' => 'any', 'posts_per_page' => -1, 'to_ping' => '', 'fields' => 'ids' ) );
+	foreach ( $trackbacks as $trackback ) {
+		do_trackbacks( $trackback );
+	}
 
 	//Do Update Services/Generic Pings
 	generic_ping();
Index: src/wp-includes/query.php
===================================================================
--- src/wp-includes/query.php	(revision 37426)
+++ src/wp-includes/query.php	(working copy)
@@ -1565,6 +1565,7 @@
 	 *     @type array        $tax_query               An associative array of WP_Tax_Query arguments.
 	 *                                                 See WP_Tax_Query->queries.
 	 *     @type string       $title                   Post title.
+	 *     @type string       $to_ping                 Post ping status. Default false.
 	 *     @type bool         $update_post_meta_cache  Whether to update the post meta cache. Default true.
 	 *     @type bool         $update_post_term_cache  Whether to update the post term cache. Default true.
 	 *     @type int          $w                       The week number of the year. Default empty. Accepts numbers 0-53.
@@ -1599,6 +1600,7 @@
 		$qv['pagename'] = trim( $qv['pagename'] );
 		$qv['name'] = trim( $qv['name'] );
 		$qv['title'] = trim( $qv['title'] );
+		$qv['to_ping'] = isset( $qv['to_ping'] ) ? $qv['to_ping'] : false;
 		if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
 		if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
 		if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']);
@@ -3076,6 +3078,10 @@
 			$post_type_object = get_post_type_object ( 'post' );
 		}
 
+		if ( $q['to_ping'] !== false ) {
+			$where .= " AND {$wpdb->posts}.to_ping = " . $q['to_ping'];
+		}
+
 		$edit_cap = 'edit_post';
 		$read_cap = 'read_post';
 
