diff --git wp-includes/nav-menu-template.php wp-includes/nav-menu-template.php
index 1dfc661..090de8f 100644
--- wp-includes/nav-menu-template.php
+++ wp-includes/nav-menu-template.php
@@ -287,8 +287,6 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
 				}
 			}
 		}
-	} elseif ( ! empty( $queried_object->post_type ) && is_post_type_hierarchical( $queried_object->post_type ) ) {
-		_get_post_ancestors( $queried_object );
 	} elseif ( ! empty( $queried_object->taxonomy ) && is_taxonomy_hierarchical( $queried_object->taxonomy ) ) {
 		$term_hierarchy = _get_term_hierarchy( $queried_object->taxonomy );
 		$term_to_ancestor = array();
diff --git wp-includes/post-template.php wp-includes/post-template.php
index 7a60672..ba136b6 100644
--- wp-includes/post-template.php
+++ wp-includes/post-template.php
@@ -1035,8 +1035,7 @@ class Walker_Page extends Walker {
 		$css_class = array('page_item', 'page-item-'.$page->ID);
 		if ( !empty($current_page) ) {
 			$_current_page = get_page( $current_page );
-			_get_post_ancestors($_current_page);
-			if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) )
+			if ( in_array( $page->ID, $_current_page->ancestors ) )
 				$css_class[] = 'current_page_ancestor';
 			if ( $page->ID == $current_page )
 				$css_class[] = 'current_page_item';
diff --git wp-includes/post.php wp-includes/post.php
index 3fcaa46..dd26731 100644
--- wp-includes/post.php
+++ wp-includes/post.php
@@ -378,7 +378,6 @@ function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
 		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');
 	} elseif ( is_object($post) && 'raw' == $post->filter ) {
@@ -394,7 +393,6 @@ function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
 			$_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id));
 			if ( ! $_post )
 				return $null;
-			_get_post_ancestors($_post);
 			$_post = sanitize_post($_post, 'raw');
 			wp_cache_add($_post->ID, $_post, 'posts');
 		}
@@ -404,6 +402,8 @@ function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
 		$_post = sanitize_post($_post, $filter);
 
 	if ( $output == OBJECT ) {
+		if ( is_a( $_post, 'stdClass' ) )
+			$_post = new _WP_Post_Wrapper( $_post );
 		return $_post;
 	} elseif ( $output == ARRAY_A ) {
 		$__post = get_object_vars($_post);
@@ -417,6 +417,43 @@ function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
 }
 
 /**
+ * Wrapper class to preserve back-compat for $post->ancestors
+ *
+ * @since 3.4.0
+ */
+class _WP_Post_Wrapper {
+
+	private $post;
+
+	function __construct( $post ) {
+		$this->post = $post;
+	}
+
+	function __isset( $key ) {
+		if ( 'ancestors' == $key )
+			return true;
+
+		return isset( $this->post->$key );
+	}
+
+	function &__get( $key ) {
+		if ( 'ancestors' == $key )
+			$ref = get_post_ancestors( $this->post );
+		else
+			$ref = &$this->post->$key;
+
+		return $ref;
+	}
+
+	function __set( $key, $value ) {
+		if ( 'ancestors' == $key )
+			return;
+
+		$this->post->$key = $value;
+	}
+}
+
+/**
  * Retrieve ancestors of a post.
  *
  * @since 2.5.0
@@ -424,13 +461,31 @@ function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
  * @param int|object $post Post ID or post object
  * @return array Ancestor IDs or empty array if none are found.
  */
-function get_post_ancestors($post) {
-	$post = get_post($post);
+function get_post_ancestors( $post ) {
+	$post = get_post( $post );
+
+	if ( !$post )
+		return false;
 
-	if ( !empty($post->ancestors) )
-		return $post->ancestors;
+	if ( ! $ancestors = wp_cache_get( $post->ID, 'post_ancestors' ) ) {
+		$ancestors = array();
+
+		if ( !empty( $post->post_parent ) && $post->ID != $post->post_parent ) {
+			$id = $ancestors[] = $post->post_parent;
+
+			while ( $ancestor = get_post( $id ) ) {
+				// Loop detection: If the ancestor has been seen before, break.
+				if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors ) )
+					break;
 
-	return array();
+				$id = $ancestors[] = $ancestor->post_parent;
+			}
+		}
+
+		wp_cache_add( $post->ID, $ancestors, 'post_ancestors' );
+	}
+
+	return $ancestors;
 }
 
 /**
@@ -3300,13 +3355,8 @@ function get_page_uri($page) {
 		$page = get_page($page);
 	$uri = $page->post_name;
 
-	// A page cannot be it's own parent.
-	if ( $page->post_parent == $page->ID )
-		return $uri;
-
-	while ($page->post_parent != 0) {
-		$page = get_page($page->post_parent);
-		$uri = $page->post_name . "/" . $uri;
+	foreach ( $page->ancestors as $parent ) {
+		$uri = get_page($parent)->post_name . "/" . $uri;
 	}
 
 	return $uri;
@@ -4613,45 +4663,6 @@ function _save_post_hook($post_id, $post) {
 }
 
 /**
- * Retrieve post ancestors and append to post ancestors property.
- *
- * Will only retrieve ancestors once, if property is already set, then nothing
- * will be done. If there is not a parent post, or post ID and post parent ID
- * are the same then nothing will be done.
- *
- * The parameter is passed by reference, so nothing needs to be returned. The
- * property will be updated and can be referenced after the function is
- * complete. The post parent will be an ancestor and the parent of the post
- * parent will be an ancestor. There will only be two ancestors at the most.
- *
- * @since 2.5.0
- * @access private
- * @uses $wpdb
- *
- * @param object $_post Post data.
- * @return null When nothing needs to be done.
- */
-function _get_post_ancestors(&$_post) {
-	global $wpdb;
-
-	if ( isset($_post->ancestors) )
-		return;
-
-	$_post->ancestors = array();
-
-	if ( empty($_post->post_parent) || $_post->ID == $_post->post_parent )
-		return;
-
-	$id = $_post->ancestors[] = $_post->post_parent;
-	while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) ) ) {
-		// Loop detection: If the ancestor has been seen before, break.
-		if ( ( $ancestor == $_post->ID ) || in_array($ancestor,  $_post->ancestors) )
-			break;
-		$id = $_post->ancestors[] = $ancestor;
-	}
-}
-
-/**
  * Determines which fields of posts are to be saved in revisions.
  *
  * Does two things. If passed a post *array*, it will return a post array ready
@@ -5338,4 +5349,4 @@ function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache
 
 		update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache );
 	}
-}
\ No newline at end of file
+}
diff --git wp-includes/taxonomy.php wp-includes/taxonomy.php
index 6334ee7..3da27dd 100644
--- wp-includes/taxonomy.php
+++ wp-includes/taxonomy.php
@@ -3206,16 +3206,8 @@ function get_ancestors($object_id = 0, $object_type = '') {
 			$ancestors[] = (int) $term->parent;
 			$term = get_term($term->parent, $object_type);
 		}
-	} elseif ( null !== get_post_type_object( $object_type ) ) {
-		$object = get_post($object_id);
-		if ( ! is_wp_error( $object ) && isset( $object->ancestors ) && is_array( $object->ancestors ) )
-			$ancestors = $object->ancestors;
-		else {
-			while ( ! is_wp_error($object) && ! empty( $object->post_parent ) && ! in_array( $object->post_parent, $ancestors ) ) {
-				$ancestors[] = (int) $object->post_parent;
-				$object = get_post($object->post_parent);
-			}
-		}
+	} elseif ( post_type_exists( $object_type ) ) {
+		$ancestors = get_post_ancestors($object_id);
 	}
 
 	return apply_filters('get_ancestors', $ancestors, $object_id, $object_type);
