### Eclipse Workspace Patch 1.0
#P wordpress-trunk
Index: wp-includes/post-template.php
===================================================================
--- wp-includes/post-template.php	(revision 12527)
+++ wp-includes/post-template.php	(working copy)
@@ -94,30 +94,34 @@
 /**
  * Retrieve post title.
  *
- * If the post is protected and the visitor is not an admin, then "Protected"
- * will be displayed before the post title. If the post is private, then
- * "Private" will be located before the post title.
+ * Get title of a post. Reflects visibility like public, password protected 
+ * or private.
  *
  * @since 0.71
  *
- * @param int $id Optional. Post ID.
- * @return string
+ * @param int $id (optional) id of post
+ * @return string title
  */
 function get_the_title( $id = 0 ) {
-	$post = &get_post($id);
+	$title  = '';
+	$format = '';
+	$post   = &get_post($id);
+	
+	if ( isset($post->ID) )
+		$id    = $post->ID;
 
-	$title = $post->post_title;
+	if ( isset($post->post_title) ) 
+		$title = $post->post_title;
 
-	if ( !is_admin() ) {
-		if ( !empty($post->post_password) ) {
-			$protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
-			$title = sprintf($protected_title_format, $title);
-		} else if ( isset($post->post_status) && 'private' == $post->post_status ) {
-			$private_title_format = apply_filters('private_title_format', __('Private: %s'));
-			$title = sprintf($private_title_format, $title);
-		}
+	if ( !is_admin() && !empty($post->post_password)) {
+		$format = apply_filters('protected_title_format', __('Protected: %s'));
+	} else if ( !is_admin() && isset($post->post_status) && 'private' == $post->post_status ) {
+		$format = apply_filters('private_title_format', __('Private: %s'));		
 	}
-	return apply_filters( 'the_title', $title, $post->ID );
+	
+	if ($format) $title = sprintf($format, $title);
+
+	return apply_filters('the_title', $title, $id);
 }
 
 /**
Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 12527)
+++ wp-includes/post.php	(working copy)
@@ -230,55 +230,82 @@
  * $post, must be given as a variable, since it is passed by reference.
  *
  * @since 1.5.1
- * @uses $wpdb
  * @link http://codex.wordpress.org/Function_Reference/get_post
  *
- * @param int|object $post Post ID or post object.
- * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N.
- * @param string $filter Optional, default is raw.
- * @return mixed Post data
+ * @param int|object $post Post ID or post object or set to 0 to get current post
+ * @param string $output (optional) default is OBJECT, can be ARRAY_A or ARRAY_N.
+ * @param string $filter (optional) default is 'raw'.
+ * @return object|array Post data based on $output parameter: OBJECT, ARRAY_A or 
+ *                      ARRAY_N. NULL if no post available.
  */
 function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
-	global $wpdb;
-	$null = null;
+	$_post = null; // init return value 
 
-	if ( empty($post) ) {
-		if ( isset($GLOBALS['post']) )
-			$_post = & $GLOBALS['post'];
-		else
-			return $null;
-	} elseif ( is_object($post) && empty($post->filter) ) {
-		_get_post_ancestors($post);
-		$_post = sanitize_post($post, 'raw');
-		wp_cache_add($post->ID, $_post, 'posts');
+	if ( empty($post) && ! isset($GLOBALS['post']) ) {
+		return $_post;
+	} else if ( empty($post) && isset($GLOBALS['post']) ) {
+		$_post = & $GLOBALS['post'];
+	} else if ( is_object($post) && empty($post->filter) ) {
+		$_post = wp_get_post($post);
 	} else {
-		if ( is_object($post) )
-			$post = $post->ID;
-		$post = (int) $post;
-		if ( ! $_post = wp_cache_get($post, 'posts') ) {
-			$_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post));
-			if ( ! $_post )
-				return $null;
-			_get_post_ancestors($_post);
-			$_post = sanitize_post($_post, 'raw');
-			wp_cache_add($_post->ID, $_post, 'posts');
+		// retrieve post by numerical ID (incl. cache roundtrip)
+		$post = (int) ( is_object($post) ? $post->ID : $post );
+		if ( ! ( $_post = wp_cache_get($post, 'posts') )
+			&& null === ( $_post = wp_get_post($post) ) ) {
+			return $_post;
 		}
 	}
 
 	if ($filter != 'raw')
 		$_post = sanitize_post($_post, $filter);
+		
+	// convert into parametrized output datatype
+		
+	if ( ARRAY_N == $ouput || ARRAY_A == $ouput )	
+		$_post = get_object_vars($_post);
+		
+	if ( ARRAY_N == $ouput )
+		$_post = array_values($_post);
+	
+	return $_post;
+}
 
-	if ( $output == OBJECT ) {
-		return $_post;
-	} elseif ( $output == ARRAY_A ) {
-		$__post = get_object_vars($_post);
-		return $__post;
-	} elseif ( $output == ARRAY_N ) {
-		$__post = array_values(get_object_vars($_post));
-		return $__post;
+/**
+ * get post object by id
+ *
+ * retrieves the data from the database, retrieves the posts 
+ * ancestors, sanitizes it with RAW context and stores it in 
+ * the cache.
+ * 
+ * @since 3.0
+ * @see get_post()
+ * 
+ * @param  int|onject $inpost id of post to get or post object
+ * @return object     post, NULL if post of id does not exists
+ * @global WPDB
+ */
+function &wp_get_post( &$inpost )
+{
+	 /* @var $wpdb WPDB */
+	global $wpdb;
+	
+	if ( is_object($inpost) ) {
+		$post =& $inpost;		
 	} else {
-		return $_post;
+		$post_id = intval($inpost);
+		$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $post_id));
 	}
+	
+	if ( ! $post )
+	{
+		$post = null;		
+	} else {	
+		_get_post_ancestors($post);
+		$post = sanitize_post($post, 'raw');
+		wp_cache_add($post->ID, $post, 'posts');
+	}
+	
+	return $post;
 }
 
 /**
@@ -859,6 +886,7 @@
 	return $post;
 }
 
+
 /**
  * Sanitize post field based on context.
  *
