Index: wp-includes/template.php
===================================================================
--- wp-includes/template.php	(revision 21827)
+++ wp-includes/template.php	(working copy)
@@ -82,8 +82,10 @@
 
 	$templates = array();
 
-	$templates[] = "author-{$author->user_nicename}.php";
-	$templates[] = "author-{$author->ID}.php";
+	if ( isset( $author->user_nicename ) )
+		$templates[] = "author-{$author->user_nicename}.php";
+	if ( isset( $author->ID ) )
+		$templates[] = "author-{$author->ID}.php";
 	$templates[] = 'author.php';
 
 	return get_query_template( 'author', $templates );
@@ -105,9 +107,10 @@
 	$category = get_queried_object();
 
 	$templates = array();
-
-	$templates[] = "category-{$category->slug}.php";
-	$templates[] = "category-{$category->term_id}.php";
+	if ( isset( $category->slug ) )
+		$templates[] = "category-{$category->slug}.php";
+	if ( isset( $category->term_id ) )	
+		$templates[] = "category-{$category->term_id}.php";
 	$templates[] = 'category.php';
 
 	return get_query_template( 'category', $templates );
@@ -130,8 +133,10 @@
 
 	$templates = array();
 
-	$templates[] = "tag-{$tag->slug}.php";
-	$templates[] = "tag-{$tag->term_id}.php";
+	if ( isset( $tag->slug ) )
+		$templates[] = "tag-{$tag->slug}.php";
+	if ( isset( $tag->term_id ) )	
+		$templates[] = "tag-{$tag->term_id}.php";
 	$templates[] = 'tag.php';
 
 	return get_query_template( 'tag', $templates );
@@ -156,12 +161,15 @@
  */
 function get_taxonomy_template() {
 	$term = get_queried_object();
-	$taxonomy = $term->taxonomy;
-
+	
 	$templates = array();
+	if ( isset( $term->taxonomy ) ) {
+		$taxonomy = $term->taxonomy;
+		if ( ! empty( $term->slug ) )
+			$templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
+		$templates[] = "taxonomy-$taxonomy.php";
+	}
 
-	$templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
-	$templates[] = "taxonomy-$taxonomy.php";
 	$templates[] = 'taxonomy.php';
 
 	return get_query_template( 'taxonomy', $templates );
@@ -280,7 +288,8 @@
 
 	$templates = array();
 
-	$templates[] = "single-{$object->post_type}.php";
+	if ( isset( $object->post_type ) )
+		$templates[] = "single-{$object->post_type}.php";
 	$templates[] = "single.php";
 
 	return get_query_template( 'single', $templates );
@@ -303,15 +312,21 @@
  */
 function get_attachment_template() {
 	global $posts;
-	$type = explode('/', $posts[0]->post_mime_type);
-	if ( $template = get_query_template($type[0]) )
-		return $template;
-	elseif ( $template = get_query_template($type[1]) )
-		return $template;
-	elseif ( $template = get_query_template("$type[0]_$type[1]") )
-		return $template;
-	else
-		return get_query_template('attachment');
+	
+	if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) ) {
+		$type = explode( '/', $posts[0]->post_mime_type );
+		
+		if ( ! empty( $type ) ) {
+			if ( $template = get_query_template( $type[0] ) )
+				return $template;
+			if ( $template = get_query_template($type[1]) )
+				return $template;
+			elseif ( $template = get_query_template("$type[0]_$type[1]") )
+				return $template;			
+		}
+	}
+		
+	return get_query_template('attachment');
 }
 
 /**
