Index: wp-includes/admin-bar.php
===================================================================
--- wp-includes/admin-bar.php	(revision 21604)
+++ wp-includes/admin-bar.php	(working copy)
@@ -419,10 +419,11 @@
  * @since 3.1.0
  */
 function wp_admin_bar_edit_menu( $wp_admin_bar ) {
-	global $post, $tag, $wp_the_query;
+	global $tag, $wp_the_query;
 
 	if ( is_admin() ) {
 		$current_screen = get_current_screen();
+		$post = get_post();
 
 		if ( 'post' == $current_screen->base
 			&& 'add' != $current_screen->action
@@ -619,7 +620,7 @@
 		return;
 
 	$title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
-	$title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>'; 
+	$title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>';
 
 	$wp_admin_bar->add_menu( array(
 		'id'    => 'updates',
Index: wp-includes/class-wp-atom-server.php
===================================================================
--- wp-includes/class-wp-atom-server.php	(revision 21604)
+++ wp-includes/class-wp-atom-server.php	(working copy)
@@ -846,10 +846,9 @@
 	 * @param int $postID Post ID.
 	 * @return string
 	 */
-	function get_entry_url($postID = null) {
+	function get_entry_url( $postID = null ) {
 		if (!isset($postID)) {
-			global $post;
-			$postID = (int) $post->ID;
+			$postID = (int) get_post()->ID;
 		}
 
 		$url = $this->app_base . $this->ENTRY_PATH . "/$postID";
@@ -878,8 +877,7 @@
 	 */
 	function get_media_url($postID = null) {
 		if (!isset($postID)) {
-			global $post;
-			$postID = (int) $post->ID;
+			$postID = (int) get_post()->ID;
 		}
 
 		$url = $this->app_base . $this->MEDIA_SINGLE_PATH ."/file/$postID";
Index: wp-includes/post-template.php
===================================================================
--- wp-includes/post-template.php	(revision 21604)
+++ wp-includes/post-template.php	(working copy)
@@ -26,8 +26,7 @@
  * @return int
  */
 function get_the_ID() {
-	global $post;
-	return $post->ID;
+	return get_post()->ID;
 }
 
 /**
@@ -97,11 +96,11 @@
  *
  * @since 0.71
  *
- * @param int $id Optional. Post ID.
+ * @param mixed $post Optional. Post ID or object.
  * @return string
  */
-function get_the_title( $id = 0 ) {
-	$post = get_post($id);
+function get_the_title( $post = 0 ) {
+	$post = get_post( $post );
 
 	$title = isset($post->post_title) ? $post->post_title : '';
 	$id = isset($post->ID) ? $post->ID : (int) $id;
@@ -178,8 +177,10 @@
  * @return string
  */
 function get_the_content($more_link_text = null, $stripteaser = false) {
-	global $post, $more, $page, $pages, $multipage, $preview;
+	global $more, $page, $pages, $multipage, $preview;
 
+	$post = get_post();
+
 	if ( null === $more_link_text )
 		$more_link_text = __( '(more...)' );
 
@@ -187,7 +188,7 @@
 	$hasTeaser = false;
 
 	// If post password required and it doesn't match the cookie.
-	if ( post_password_required($post) )
+	if ( post_password_required() )
 		return get_the_password_form();
 
 	if ( $page > count($pages) ) // if the requested page doesn't exist
@@ -259,8 +260,7 @@
 	if ( !empty( $deprecated ) )
 		_deprecated_argument( __FUNCTION__, '2.3' );
 
-	global $post;
-	if ( post_password_required($post) ) {
+	if ( post_password_required() ) {
 		return __( 'There is no excerpt because this is a protected post.' );
 	}
 
@@ -676,7 +676,8 @@
  * @return string Link.
  */
 function _wp_link_page( $i ) {
-	global $post, $wp_rewrite;
+	global $wp_rewrite;
+	$post = get_post();
 
 	if ( 1 == $i ) {
 		$url = get_permalink();
@@ -1171,7 +1172,7 @@
  * @return string
  */
 function prepend_attachment($content) {
-	global $post;
+	$post = get_post();
 
 	if ( empty($post->post_type) || $post->post_type != 'attachment' )
 		return $content;
@@ -1198,7 +1199,7 @@
  * @return string HTML content for password form for password protected post.
  */
 function get_the_password_form() {
-	global $post;
+	$post = get_post();
 	$label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
 	$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
 	<p>' . __("This post is password protected. To view it please enter your password below:") . '</p>
Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 21604)
+++ wp-includes/post.php	(working copy)
@@ -372,12 +372,12 @@
  * @uses $wpdb
  * @link http://codex.wordpress.org/Function_Reference/get_post
  *
- * @param int|object $post Post ID or post object.
+ * @param int|object $post Post ID or post object. Optional, default is the current post from the loop.
  * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N.
  * @param string $filter Optional, default is raw.
  * @return WP_Post|null WP_Post on success or null on failure
  */
-function get_post( $post, $output = OBJECT, $filter = 'raw' ) {
+function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
 	if ( empty( $post ) && isset( $GLOBALS['post'] ) )
 		$post = $GLOBALS['post'];
 
@@ -914,20 +914,13 @@
  *
  * @uses $post The Loop current post global
  *
- * @param mixed $the_post Optional. Post object or post ID.
+ * @param mixed $post Optional. Post object or post ID.
  * @return bool|string post type or false on failure.
  */
-function get_post_type( $the_post = false ) {
-	global $post;
+function get_post_type( $post = null ) {
+	if ( $post = get_post( $post ) )
+		return $post->post_type;
 
-	if ( false === $the_post )
-		$the_post = $post;
-	elseif ( is_numeric($the_post) )
-		$the_post = get_post($the_post);
-
-	if ( is_object($the_post) )
-		return $the_post->post_type;
-
 	return false;
 }
 
@@ -1152,7 +1145,7 @@
 			$args->rewrite['with_front'] = true;
 		if ( ! isset( $args->rewrite['pages'] ) )
 			$args->rewrite['pages'] = true;
-		if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive )
+		if ( ! isset( $args->rewrite['feeds'] ) && isset( $args->has_archive ) )
 			$args->rewrite['feeds'] = (bool) $args->has_archive;
 		if ( ! isset( $args->rewrite['ep_mask'] ) ) {
 			if ( isset( $args->permalink_epmask ) )
@@ -1166,19 +1159,21 @@
 		else
 			add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
 
-		if ( $args->has_archive ) {
-			$archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
-			if ( $args->rewrite['with_front'] )
-				$archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
-			else
-				$archive_slug = $wp_rewrite->root . $archive_slug;
+		$archive_slug = is_string( $args->has_archive ) && $args->has_archive ? $args->has_archive : $args->rewrite['slug'];
+		if ( $args->rewrite['with_front'] )
+			$archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
+		else
+			$archive_slug = $wp_rewrite->root . $archive_slug;
 
+		// Feed support can be added even without an archive.
+		if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {
+			$feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
+			add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
+			add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
+		}
+
+		if ( $args->has_archive ) {
 			add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' );
-			if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {
-				$feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
-				add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
-				add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
-			}
 			if ( $args->rewrite['pages'] )
 				add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );
 		}
Index: wp-includes/comment-template.php
===================================================================
--- wp-includes/comment-template.php	(revision 21604)
+++ wp-includes/comment-template.php	(working copy)
@@ -810,12 +810,9 @@
  * @uses $post Gets the ID of the current post for the token
  */
 function wp_comment_form_unfiltered_html_nonce() {
-	global $post;
+	$post = get_post();
+	$post_id = $post ? $post->ID : 0;
 
-	$post_id = 0;
-	if ( !empty($post) )
-		$post_id = $post->ID;
-
 	if ( current_user_can( 'unfiltered_html' ) ) {
 		wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false );
 		echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n";
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 21604)
+++ wp-includes/media.php	(working copy)
@@ -775,7 +775,7 @@
  * @return string HTML content to display gallery.
  */
 function gallery_shortcode($attr) {
-	global $post;
+	$post = get_post();
 
 	static $instance = 0;
 	$instance++;
@@ -928,8 +928,7 @@
  * @param bool $prev Optional. Default is true to display previous link, false for next.
  */
 function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) {
-	global $post;
-	$post = get_post($post);
+	$post = get_post();
 	$attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ));
 
 	foreach ( $attachments as $k => $attachment )
@@ -1102,16 +1101,16 @@
 	 * an AJAX request that will call WP_Embed::cache_oembed().
 	 */
 	function maybe_run_ajax_cache() {
-		global $post_ID;
+		$post = get_post();
 
-		if ( empty($post_ID) || empty($_GET['message']) || 1 != $_GET['message'] )
+		if ( ! $post || empty($_GET['message']) || 1 != $_GET['message'] )
 			return;
 
 ?>
 <script type="text/javascript">
 /* <![CDATA[ */
 	jQuery(document).ready(function($){
-		$.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post_ID, 'relative' ); ?>");
+		$.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post->ID, 'relative' ); ?>");
 	});
 /* ]]> */
 </script>
@@ -1167,7 +1166,7 @@
 	 * @return string The embed HTML on success, otherwise the original URL.
 	 */
 	function shortcode( $attr, $url = '' ) {
-		global $post;
+		$post = get_post();
 
 		if ( empty($url) )
 			return '';
Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 21604)
+++ wp-includes/link-template.php	(working copy)
@@ -55,7 +55,7 @@
  * @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'.
  */
 function permalink_anchor($mode = 'id') {
-	global $post;
+	$post = get_post();
 	switch ( strtolower($mode) ) {
 		case 'title':
 			$title = sanitize_title($post->post_title) . '-' . $post->ID;
@@ -232,24 +232,20 @@
  *
  * @since 1.5.0
  *
- * @param int $id Optional. Post ID.
+ * @param mixed $post Optional. Post ID or object.
  * @param bool $leavename Optional, defaults to false. Whether to keep page name.
  * @param bool $sample Optional, defaults to false. Is it a sample permalink.
  * @return string
  */
-function get_page_link( $id = false, $leavename = false, $sample = false ) {
-	global $post;
+function get_page_link( $post = false, $leavename = false, $sample = false ) {
+	$post = get_post( $post );
 
-	$id = (int) $id;
-	if ( !$id )
-		$id = (int) $post->ID;
-
-	if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
+	if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) )
 		$link = home_url('/');
 	else
-		$link = _get_page_link( $id , $leavename, $sample );
+		$link = _get_page_link( $post, $leavename, $sample );
 
-	return apply_filters('page_link', $link, $id, $sample);
+	return apply_filters( 'page_link', $link, $post->ID, $sample );
 }
 
 /**
@@ -260,15 +256,15 @@
  * @since 2.1.0
  * @access private
  *
- * @param int $id Optional. Post ID.
+ * @param mixed $post Optional. Post ID or object.
  * @param bool $leavename Optional. Leave name.
  * @param bool $sample Optional. Sample permalink.
  * @return string
  */
-function _get_page_link( $id = false, $leavename = false, $sample = false ) {
+function _get_page_link( $post = false, $leavename = false, $sample = false ) {
 	global $wp_rewrite;
 
-	$post = get_post( $id );
+	$post = get_post( $post );
 
 	$draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
 
@@ -276,16 +272,16 @@
 
 	if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) {
 		if ( ! $leavename ) {
-			$link = str_replace('%pagename%', get_page_uri($id), $link);
+			$link = str_replace('%pagename%', get_page_uri( $post ), $link);
 		}
 
 		$link = home_url($link);
 		$link = user_trailingslashit($link, 'page');
 	} else {
-		$link = home_url("?page_id=$id");
+		$link = home_url( '?page_id=' . $post->ID );
 	}
 
-	return apply_filters( '_get_page_link', $link, $id );
+	return apply_filters( '_get_page_link', $link, $post->ID );
 }
 
 /**
@@ -295,29 +291,27 @@
  *
  * @since 2.0.0
  *
- * @param int $id Optional. Post ID.
+ * @param mixed $post Optional. Post ID or object.
  * @return string
  */
-function get_attachment_link($id = false) {
-	global $post, $wp_rewrite;
+function get_attachment_link( $post = null ) {
+	global $wp_rewrite;
 
 	$link = false;
 
-	if ( ! $id)
-		$id = (int) $post->ID;
+	$post = get_post( $post );
 
-	$object = get_post($id);
-	if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) && ($object->post_parent != $id) ) {
-		$parent = get_post($object->post_parent);
+	if ( $wp_rewrite->using_permalinks() && ($post->post_parent > 0) && ($post->post_parent != $id) ) {
+		$parent = get_post($post->post_parent);
 		if ( 'page' == $parent->post_type )
-			$parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front
+			$parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
 		else
-			$parentlink = get_permalink( $object->post_parent );
+			$parentlink = get_permalink( $post->post_parent );
 
-		if ( is_numeric($object->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
-			$name = 'attachment/' . $object->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
+		if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
+			$name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
 		else
-			$name = $object->post_name;
+			$name = $post->post_name;
 
 		if ( strpos($parentlink, '?') === false )
 			$link = user_trailingslashit( trailingslashit($parentlink) . $name );
@@ -1122,9 +1116,9 @@
  * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
  */
 function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $previous = true ) {
-	global $post, $wpdb;
+	global $wpdb;
 
-	if ( empty( $post ) )
+	if ( ! $post = get_post() )
 		return null;
 
 	$current_post_date = $post->post_date;
@@ -1200,10 +1194,10 @@
  * @return string
  */
 function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) {
-	if ( $previous && is_attachment() && is_object( $GLOBALS['post'] ) )
-		$post = get_post($GLOBALS['post']->post_parent);
+	if ( $previous && is_attachment() && $post = get_post() )
+		$post = get_post( $post->post_parent );
 	else
-		$post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);
+		$post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous );
 
 	if ( empty($post) )
 		return;
@@ -1292,9 +1286,8 @@
  * @return object
  */
 function get_boundary_post( $in_same_cat = false, $excluded_categories = '', $start = true ) {
-	global $post;
-
-	if ( empty($post) || ! is_single() || is_attachment() )
+	$post = get_post();
+	if ( ! $post || ! is_single() || is_attachment() )
 		return null;
 
 	$cat_array = array();
@@ -1366,7 +1359,7 @@
  */
 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
 	if ( $previous && is_attachment() )
-		$post = get_post($GLOBALS['post']->post_parent);
+		$post = get_post( get_post()->post_parent );
 	else
 		$post = get_adjacent_post($in_same_cat, $excluded_categories, $previous);
 
@@ -1673,11 +1666,11 @@
  * @return string
  */
 function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
-	global $post, $wp_rewrite;
+	global $wp_rewrite;
 
 	$pagenum = (int) $pagenum;
 
-	$result = get_permalink( $post->ID );
+	$result = get_permalink();
 
 	if ( 'newest' == get_option('default_comments_page') ) {
 		if ( $pagenum != $max_page ) {
@@ -2438,15 +2431,13 @@
  * @param string $after Optional HTML to display after the link.
  */
 function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
-	global $post;
-
 	if ( empty( $text ) )
 		$text = __('This is the short link.');
 
 	if ( empty( $title ) )
 		$title = the_title_attribute( array( 'echo' => false ) );
 
-	$shortlink = wp_get_shortlink( $post->ID );
+	$shortlink = wp_get_shortlink();
 
 	if ( !empty( $shortlink ) ) {
 		$link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>';
Index: wp-includes/author-template.php
===================================================================
--- wp-includes/author-template.php	(revision 21604)
+++ wp-includes/author-template.php	(working copy)
@@ -69,8 +69,7 @@
  * @return string The author's display name.
  */
 function get_the_modified_author() {
-	global $post;
-	if ( $last_id = get_post_meta($post->ID, '_edit_last', true) ) {
+	if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true) ) {
 		$last_user = get_userdata($last_id);
 		return apply_filters('the_modified_author', $last_user->display_name);
 	}
@@ -164,8 +163,7 @@
  * @return int The number of posts by the author.
  */
 function get_the_author_posts() {
-	global $post;
-	return count_user_posts($post->post_author);
+	return count_user_posts( get_post()->post_author );
 }
 
 /**
Index: wp-includes/general-template.php
===================================================================
--- wp-includes/general-template.php	(revision 21610)
+++ wp-includes/general-template.php	(working copy)
@@ -1311,8 +1311,7 @@
  * @since 1.0.0
  */
 function the_date_xml() {
-	global $post;
-	echo mysql2date('Y-m-d', $post->post_date, false);
+	echo mysql2date( 'Y-m-d', get_post()->post_date, false );
 }
 
 /**
@@ -1367,7 +1366,7 @@
  * @return string|null Null if displaying, string if retrieving.
  */
 function get_the_date( $d = '' ) {
-	global $post;
+	$post = get_post();
 	$the_date = '';
 
 	if ( '' == $d )
@@ -1528,8 +1527,8 @@
  * @uses $post
  */
 function the_weekday() {
-	global $wp_locale, $post;
-	$the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
+	global $wp_locale;
+	$the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
 	$the_weekday = apply_filters('the_weekday', $the_weekday);
 	echo $the_weekday;
 }
@@ -1546,11 +1545,11 @@
  * @param string $after Optional Output after the date.
  */
 function the_weekday_date($before='',$after='') {
-	global $wp_locale, $post, $day, $previousweekday;
+	global $wp_locale, $day, $previousweekday;
 	$the_weekday_date = '';
 	if ( $currentday != $previousweekday ) {
 		$the_weekday_date .= $before;
-		$the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
+		$the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
 		$the_weekday_date .= $after;
 		$previousweekday = $currentday;
 	}
Index: wp-includes/deprecated.php
===================================================================
--- wp-includes/deprecated.php	(revision 21604)
+++ wp-includes/deprecated.php	(working copy)
@@ -57,14 +57,14 @@
  * @deprecated Use The Loop - {@link http://codex.wordpress.org/The_Loop Use new WordPress Loop}
  */
 function start_wp() {
-	global $wp_query, $post;
+	global $wp_query;
 
 	_deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') );
 
 	// Since the old style loop is being used, advance the query iterator here.
 	$wp_query->next_post();
 
-	setup_postdata($post);
+	setup_postdata( get_post() );
 }
 
 /**
Index: wp-includes/class-wp-editor.php
===================================================================
--- wp-includes/class-wp-editor.php	(revision 21604)
+++ wp-includes/class-wp-editor.php	(working copy)
@@ -126,7 +126,7 @@
 	}
 
 	public static function editor_settings($editor_id, $set) {
-		global $editor_styles, $post;
+		global $editor_styles;
 		$first_run = false;
 
 		if ( empty(self::$first_init) ) {
@@ -370,8 +370,8 @@
 
 			$body_class = $editor_id;
 
-			if ( isset($post) )
-				$body_class .= " post-type-$post->post_type";
+			if ( $post = get_post() )
+				$body_class .= ' post-type-' . $post->post_type;
 
 			if ( !empty($set['tinymce']['body_class']) ) {
 				$body_class .= ' ' . $set['tinymce']['body_class'];
@@ -612,7 +612,8 @@
 	}
 
 	public static function wp_fullscreen_html() {
-		global $content_width, $post;
+		global $content_width;
+		$post = get_post();
 
 		$width = isset($content_width) && 800 > $content_width ? $content_width : 800;
 		$width = $width + 22; // compensate for the padding and border
Index: wp-includes/category-template.php
===================================================================
--- wp-includes/category-template.php	(revision 21604)
+++ wp-includes/category-template.php	(working copy)
@@ -1054,29 +1054,21 @@
  *
  * @since 2.5.0
  *
- * @param int $id Post ID.
+ * @param mixed $post Post ID or object.
  * @param string $taxonomy Taxonomy name.
  * @return array|bool False on failure. Array of term objects on success.
  */
-function get_the_terms( $id, $taxonomy ) {
-	global $post;
+function get_the_terms( $post, $taxonomy ) {
+	if ( ! $post = get_post( $post ) )
+		return false;
 
- 	$id = (int) $id;
-
-	if ( !$id ) {
-		if ( empty( $post->ID ) )
-			return false;
-		else
-			$id = (int) $post->ID;
-	}
-
-	$terms = get_object_term_cache( $id, $taxonomy );
+	$terms = get_object_term_cache( $post->ID, $taxonomy );
 	if ( false === $terms ) {
-		$terms = wp_get_object_terms( $id, $taxonomy );
-		wp_cache_add($id, $terms, $taxonomy . '_relationships');
+		$terms = wp_get_object_terms( $post->ID, $taxonomy );
+		wp_cache_add($post->ID, $terms, $taxonomy . '_relationships');
 	}
 
-	$terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy );
+	$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
 
 	if ( empty( $terms ) )
 		return false;
Index: wp-admin/includes/class-wp-posts-list-table.php
===================================================================
--- wp-admin/includes/class-wp-posts-list-table.php	(revision 21604)
+++ wp-admin/includes/class-wp-posts-list-table.php	(working copy)
@@ -316,7 +316,8 @@
 	}
 
 	function _display_rows( $posts, $level = 0 ) {
-		global $post, $mode;
+		global $mode;
+		$post = get_post();
 
 		// Create array of post IDs.
 		$post_ids = array();
@@ -458,12 +459,12 @@
 		unset( $children_pages[$parent] ); //required in order to keep track of orphans
 	}
 
-	function single_row( $a_post, $level = 0 ) {
-		global $post, $mode;
+	function single_row( $post, $level = 0 ) {
+		global $mode;
 		static $alternate;
 
-		$global_post = $post;
-		$post = $a_post;
+		$global_post = get_post();
+		$GLOBALS['post'] = $post;
 		setup_postdata( $post );
 
 		$edit_link = get_edit_post_link( $post->ID );
@@ -529,7 +530,7 @@
 				}
 				else {
 					$attributes = 'class="post-title page-title column-title"' . $style;
-					
+
 					$pad = str_repeat( '&#8212; ', $level );
 ?>
 			<td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); ?></strong>
@@ -684,7 +685,7 @@
 	?>
 		</tr>
 	<?php
-		$post = $global_post;
+		$GLOBALS['post'] = $global_post;
 	}
 
 	/**
Index: wp-admin/includes/class-wp-media-list-table.php
===================================================================
--- wp-admin/includes/class-wp-media-list-table.php	(revision 21604)
+++ wp-admin/includes/class-wp-media-list-table.php	(working copy)
@@ -156,7 +156,8 @@
 	}
 
 	function display_rows() {
-		global $post, $id;
+		$post = get_post();
+		$id = $post->ID;
 
 		add_filter( 'the_title','esc_html' );
 		$alt = '';
Index: wp-admin/includes/post.php
===================================================================
--- wp-admin/includes/post.php	(revision 21604)
+++ wp-admin/includes/post.php	(working copy)
@@ -928,7 +928,7 @@
 /**
  * Executes a query for attachments. An array of WP_Query arguments
  * can be passed in, which will override the arguments set by this function.
- * 
+ *
  * @since 2.5.0
  * @uses apply_filters() Calls 'upload_per_page' on posts_per_page argument
  *
@@ -1139,16 +1139,15 @@
  * @since 2.9.0
  *
  * @param int $thumbnail_id ID of the attachment used for thumbnail
- * @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID
+ * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
  * @return string html
  */
-function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) {
-	global $content_width, $_wp_additional_image_sizes, $post_ID;
+function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
+	global $content_width, $_wp_additional_image_sizes;
 
-	if ( empty( $post_id ) )
-		$post_id = $post_ID;
+	$post = get_post( $post );
 
-	$upload_iframe_src = esc_url( get_upload_iframe_src('image', $post_id) );
+	$upload_iframe_src = esc_url( get_upload_iframe_src('image', $post->ID ) );
 	$set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
 	$content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) );
 
@@ -1160,14 +1159,14 @@
 		else
 			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
 		if ( !empty( $thumbnail_html ) ) {
-			$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_id" );
+			$ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
 			$content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html );
 			$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>';
 		}
 		$content_width = $old_content_width;
 	}
 
-	return apply_filters( 'admin_post_thumbnail_html', $content, $post_id );
+	return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID );
 }
 
 /**
@@ -1225,8 +1224,7 @@
  * @return none
  */
 function _admin_notice_post_locked() {
-	global $post;
-
+	$post = get_post();
 	$lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) );
 	$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
 	$last_user = get_userdata( $user );
Index: wp-admin/includes/meta-boxes.php
===================================================================
--- wp-admin/includes/meta-boxes.php	(revision 21604)
+++ wp-admin/includes/meta-boxes.php	(working copy)
@@ -469,14 +469,14 @@
  * @param object $post
  */
 function post_comment_meta_box($post) {
-	global $wpdb, $post_ID;
+	global $wpdb;
 
 	wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
 	?>
 	<p class="hide-if-no-js" id="add-new-comment"><a href="#commentstatusdiv" onclick="commentReply.addcomment(<?php echo $post_ID; ?>);return false;"><?php _e('Add comment'); ?></a></p>
 	<?php
 
-	$total = get_comments( array( 'post_id' => $post_ID, 'number' => 1, 'count' => true ) );
+	$total = get_comments( array( 'post_id' => $post->ID, 'number' => 1, 'count' => true ) );
 	$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
 	$wp_list_table->display( true );
 
@@ -912,8 +912,7 @@
  *
  * @since 2.9.0
  */
-function post_thumbnail_meta_box() {
-	global $post;
+function post_thumbnail_meta_box( $post ) {
 	$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
 	echo _wp_post_thumbnail_html( $thumbnail_id );
 }
Index: wp-admin/includes/class-wp-comments-list-table.php
===================================================================
--- wp-admin/includes/class-wp-comments-list-table.php	(revision 21604)
+++ wp-admin/includes/class-wp-comments-list-table.php	(working copy)
@@ -302,7 +302,8 @@
 	}
 
 	function single_row( $a_comment ) {
-		global $post, $comment;
+		global $comment;
+		$post = get_post();
 
 		$comment = $a_comment;
 		$the_comment_class = join( ' ', get_comment_class( wp_get_comment_status( $comment->comment_ID ) ) );
@@ -325,7 +326,8 @@
 	}
 
 	function column_comment( $comment ) {
-		global $post, $comment_status;
+		global $comment_status;
+		$post = get_post();
 
 		$user_can = $this->user_can;
 
@@ -479,7 +481,7 @@
 	}
 
 	function column_response( $comment ) {
-		global $post;
+		$post = get_post();
 
 		if ( isset( $this->pending_count[$post->ID] ) ) {
 			$pending_comments = $this->pending_count[$post->ID];
Index: wp-admin/includes/template.php
===================================================================
--- wp-admin/includes/template.php	(revision 21604)
+++ wp-admin/includes/template.php	(working copy)
@@ -166,10 +166,9 @@
  * @return array List of popular term IDs.
  */
 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
-	global $post_ID;
-
-	if ( $post_ID )
-		$checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids'));
+	$post = get_post();
+	if ( $post->ID )
+		$checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids'));
 	else
 		$checked_terms = array();
 
@@ -575,7 +574,8 @@
  * @param unknown_type $multi
  */
 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
-	global $wp_locale, $post, $comment;
+	global $wp_locale, $comment;
+	$post = get_post();
 
 	if ( $for_post )
 		$edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
@@ -670,17 +670,16 @@
  * @return unknown
  */
 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
-	global $wpdb, $post_ID;
+	global $wpdb;
+	$post = get_post();
 	$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );
 
 	if ( $items ) {
 		foreach ( $items as $item ) {
 			// A page cannot be its own parent.
-			if (!empty ( $post_ID ) ) {
-				if ( $item->ID == $post_ID ) {
-					continue;
-				}
-			}
+			if ( $post->ID && $item->ID == $post->ID )
+				continue;
+
 			$pad = str_repeat( '&nbsp;', $level * 3 );
 			if ( $item->ID == $default)
 				$current = ' selected="selected"';
@@ -1345,8 +1344,9 @@
  * @since 2.7.0
  */
 function the_post_password() {
-	global $post;
-	if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
+	$post = get_post();
+	if ( isset( $post->post_password ) )
+		echo esc_attr( $post->post_password );
 }
 
 /**
@@ -1356,11 +1356,11 @@
  * returned.
  *
  * @since 2.7.0
- * @param int $post_id The post id. If not supplied the global $post is used.
+ * @param mixed $post Post id or object. If not supplied the global $post is used.
  * @return string The post title if set
  */
-function _draft_or_post_title( $post_id = 0 ) {
-	$title = get_the_title($post_id);
+function _draft_or_post_title( $post = 0 ) {
+	$title = get_the_title( $post );
 	if ( empty($title) )
 		$title = __('(no title)');
 	return $title;
Index: wp-admin/includes/export.php
===================================================================
--- wp-admin/includes/export.php	(revision 21604)
+++ wp-admin/includes/export.php	(working copy)
@@ -279,7 +279,7 @@
 	 * @since 2.3.0
 	 */
 	function wxr_post_taxonomy() {
-		global $post;
+		$post = get_post();
 
 		$taxonomies = get_object_taxonomies( $post->post_type );
 		if ( empty( $taxonomies ) )
