Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 15448)
+++ wp-includes/post.php	(working copy)
@@ -401,6 +401,84 @@
 }
 
 /**
+ * Retrieves post data by a given field.
+ *
+ * See {@link &get_post()} for optional filter and output arguments values.
+ *
+ * @since 3.1.0
+ *
+ * @param string $field The field to retrieve the post with.  id | title | path
+ * @param int|string $value A value for $field.  A post ID, title, or path.
+ * @param string|array $args List of arguments to overwrite the defaults
+ *        string $post_type Optional. Post type. Default post.
+ *        string $output Optional. Output type.
+ *        string $filter How the return value should be filtered.
+ * @return mixed
+ */
+function get_post_by($field, $value, $args = '') {
+	global $wpdb;
+
+	$defaults = array(
+		'post_type' => 'post', 'output' => 'OBJECT',
+		'filter' => 'raw'
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	switch ($field) {
+		case 'id':
+			$p = get_post( $value, $output, $filter );
+			if ( $p->post_type == $post_type )
+				return $p;
+			else
+				return null;
+			break;
+			
+		case 'title':
+			$post = $wpdb->get_var( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_title = %s AND post_type = %s", $value, $post_type ) );
+			if ( $post )
+				return $post;
+			else
+				return null;
+			break;
+			
+		case 'path':
+			$page_path = rawurlencode( urldecode( $value ) );
+			$page_path = str_replace( '%2F', '/', $page_path );
+			$page_path = str_replace( '%20', ' ', $page_path );
+			$page_paths = '/' . trim( $page_path, '/' );
+			$leaf_path  = sanitize_title( basename( $page_paths ) );
+			$page_paths = explode( '/', $page_paths );
+			$full_path = '';
+			foreach ( (array) $page_paths as $pathdir )
+				$full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir );
+
+			$pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = %s OR post_type = 'attachment')", $leaf_path, $post_type ));
+
+			if ( empty( $pages ) )
+				return null;
+
+			foreach ( $pages as $page ) {
+				$path = '/' . $leaf_path;
+				$curpage = $page;
+				while ( $curpage->post_parent != 0 ) {
+					$curpage = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = %d and post_type = %s", $curpage->post_parent, $post_type ) );
+					$path = '/' . $curpage->post_name . $path;
+				}
+
+				if ( $path == $full_path )
+					return get_post( $page->ID, $output, $filter );
+			}
+			break;
+			
+		default:
+			return null;
+	}
+	
+}
+
+/**
  * Retrieve ancestors of a post.
  *
  * @since 2.5.0
@@ -2888,35 +2966,10 @@
  * @return mixed Null when complete.
  */
 function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
-	global $wpdb;
-	$page_path = rawurlencode(urldecode($page_path));
-	$page_path = str_replace('%2F', '/', $page_path);
-	$page_path = str_replace('%20', ' ', $page_path);
-	$page_paths = '/' . trim($page_path, '/');
-	$leaf_path  = sanitize_title(basename($page_paths));
-	$page_paths = explode('/', $page_paths);
-	$full_path = '';
-	foreach ( (array) $page_paths as $pathdir )
-		$full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir);
-
-	$pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = %s OR post_type = 'attachment')", $leaf_path, $post_type ));
-
-	if ( empty($pages) )
-		return null;
-
-	foreach ( $pages as $page ) {
-		$path = '/' . $leaf_path;
-		$curpage = $page;
-		while ( $curpage->post_parent != 0 ) {
-			$curpage = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = %d and post_type = %s", $curpage->post_parent, $post_type ));
-			$path = '/' . $curpage->post_name . $path;
-		}
-
-		if ( $path == $full_path )
-			return get_page($page->ID, $output, $post_type);
-	}
-
-	return null;
+	$args = array(
+		'output' => $output, 'post_type' => $post_type
+	);
+	return get_post_by('path', $page_path, $args);
 }
 
 /**
@@ -2931,12 +2984,10 @@
  * @return mixed
  */
 function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) {
-	global $wpdb;
-	$page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) );
-	if ( $page )
-		return get_page($page, $output);
-
-	return null;
+	$args = array(
+		'output' => $output, 'post_type' => $post_type
+	);
+	return get_post_by('title', $page_title, $args);
 }
 
 /**
