Index: wp-includes/post-template.php
===================================================================
--- wp-includes/post-template.php	(revision 12149)
+++ wp-includes/post-template.php	(working copy)
@@ -361,7 +361,7 @@
  * @return array Array of classes.
  */
 function get_body_class( $class = '' ) {
-	global $wp_query, $wpdb, $current_user;
+	global $wp_query, $current_user;
 
 	$classes = array();
 
@@ -386,14 +386,12 @@
 		$classes[] = 'error404';
 
 	if ( is_single() ) {
-		$wp_query->post = $wp_query->posts[0];
-		setup_postdata($wp_query->post);
-
-		$postID = $wp_query->post->ID;
+		$postID = $wp_query->get_queried_object_id();
+		
 		$classes[] = 'single postid-' . $postID;
 
 		if ( is_attachment() ) {
-			$mime_type = get_post_mime_type();
+			$mime_type = get_post_mime_type($postID);
 			$mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
 			$classes[] = 'attachmentid-' . $postID;
 			$classes[] = 'attachment-' . str_replace($mime_prefix, '', $mime_type);
@@ -415,19 +413,20 @@
 	} elseif ( is_page() ) {
 		$classes[] = 'page';
 
-		$wp_query->post = $wp_query->posts[0];
-		setup_postdata($wp_query->post);
+		$pageID = $wp_query->get_queried_object_id();
 
-		$pageID = $wp_query->post->ID;
+		$post = get_page($pageID);
 
 		$classes[] = 'page-id-' . $pageID;
 
-		if ( $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' LIMIT 1", $pageID) ) )
+		$children = get_pages(array('hierarchical' => false, 'parent' => $pageID, 'number' => 1));
+		if ( ! empty( $children ) ) {
 			$classes[] = 'page-parent';
+		}
 
-		if ( $wp_query->post->post_parent ) {
+		if ( $post->post_parent ) {
 			$classes[] = 'page-child';
-			$classes[] = 'parent-pageid-' . $wp_query->post->post_parent;
+			$classes[] = 'parent-pageid-' . $post->post_parent;
 		}
 		if ( is_page_template() ) {
 			$classes[] = 'page-template';
