Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 7509)
+++ wp-includes/taxonomy.php	(working copy)
@@ -34,15 +34,23 @@
  *
  * @uses $wp_taxonomies
  *
- * @param array|string $object_type Name of the type of taxonomy object
+ * @param array|string|object $object Name of the type of taxonomy object, or an object (row from posts)
  * @return array The names of all taxonomy of $object_type.
  */
-function get_object_taxonomies($object_type) {
+function get_object_taxonomies($object) {
 	global $wp_taxonomies;
 
+	if ( is_object($object) ) {
+		if ( $object->post_type == 'attachment' )
+			return get_attachment_taxonomies($object);
+		$object = $object->post_type;
+	}
+
+	$object = (array) $object;
+
 	$taxonomies = array();
 	foreach ( $wp_taxonomies as $taxonomy ) {
-		if ( in_array($object_type, (array) $taxonomy->object_type) )
+		if ( array_intersect($object, (array) $taxonomy->object_type) )
 			$taxonomies[] = $taxonomy->name;
 	}
 
@@ -156,7 +164,7 @@
 		if ( !isset($args['rewrite']['slug']) )
 			$args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy);
 		$wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', "taxonomy=$taxonomy&term=");
-		$wp_rewrite->add_permastruct("{$args['rewrite']['slug']}/%$taxonomy%");
+		$wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%");
 	}
 
 	$args['name'] = $taxonomy;
@@ -1036,6 +1044,22 @@
 
 	$defaults = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all');
 	$args = wp_parse_args( $args, $defaults );
+
+	$terms = array();
+	if ( count($taxonomies) > 1 ) {
+		foreach ( $taxonomies as $index => $taxonomy ) {
+			$t = get_taxonomy($taxonomy);
+			if ( is_array($t->args) && $args != array_merge($args, $t->args) ) {
+				unset($taxonomies[$index]);
+				$terms = array_merge($terms, wp_get_object_terms($object_ids, $taxonomy, array_merge($args, $t->args)));
+			}
+		}
+	} else {
+		$t = get_taxonomy($taxonomies[0]);
+		if ( is_array($t->args) )
+			$args = array_merge($args, $t->args);
+	}
+
 	extract($args, EXTR_SKIP);
 
 	if ( 'count' == $orderby )
@@ -1067,10 +1091,10 @@
 	$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) ORDER BY $orderby $order";
 
 	if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
-		$terms = $wpdb->get_results($query);
+		$terms = array_merge($terms, $wpdb->get_results($query));
 		update_term_cache($terms);
 	} else if ( 'ids' == $fields || 'names' == $fields ) {
-		$terms = $wpdb->get_col($query);
+		$terms = array_merge($terms, $wpdb->get_col($query));
 	} else if ( 'tt_ids' == $fields ) {
 		$terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) ORDER BY tr.term_taxonomy_id $order");
 	}
@@ -1899,4 +1923,80 @@
 	}
 }
 
+/**
+ * get_term_link() - Generates a permalink for a taxonomy term archive
+ *
+ * @param object|int|string $term
+ * @param string $taxonomy
+ * @return string HTML link to taxonomy term archive
+ */
+function get_term_link( $term, $taxonomy ) {
+	global $wp_rewrite;
+
+	$termlink = $wp_rewrite->get_extra_permastruct($taxonomy);
+
+	if ( !is_object($term) ) {
+		if ( is_int($term) ) {
+			$term = &get_term($term, $taxonomy);
+		} else {
+			$term = &get_term_by('slug', $term, $taxonomy);
+			if ( is_wp_error($term) )
+				return $term;
+		}
+	}
+	if ( is_wp_error( $term ) )
+		return $term;
+
+	$slug = $term->slug;
+
+	if ( empty($termlink) ) {
+		$file = get_option('home') . '/';
+		$termlink = "$file?taxonomy=$taxonomy&term=$slug";
+	} else {
+		$termlink = str_replace("%$taxonomy%", $slug, $termlink);
+		$termlink = get_option('home') . user_trailingslashit($termlink, 'category');
+	}
+	return apply_filters('term_link', $termlink, $term, $taxonomy);
+}
+
+function the_taxonomies($post = 0) {
+	echo join(' ', get_the_taxonomies($post));
+}
+
+function get_the_taxonomies($post = 0) {
+	if ( is_int($post) )
+		$post =& get_post($post);
+	elseif ( !is_object($post) )
+		$post =& $GLOBALS['post'];
+
+	$taxonomies = array();
+
+	if ( !$post )
+		return $taxonomies;
+
+	$_template = '%2$s: %1$l.';
+
+	foreach ( get_object_taxonomies($post) as $taxonomy ) {
+		$t = (array) get_taxonomy($taxonomy);
+		if ( empty($t['label']) )
+			$t['label'] = $taxonomy;
+		if ( empty($t['args']) )
+			$t['args'] = array();
+		if ( empty($t['template']) )
+			$t['template'] = $_template;
+
+		$terms = get_object_term_cache($post->ID, $taxonomy);
+		if ( empty($terms) )
+			$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']);
+
+		$links = array();
+
+		foreach ( $terms as $term )
+			$links[] = "<a href='" . attribute_escape(get_term_link($term, $taxonomy)) . "'>$term->name</a>";
+
+		if ( $links )
+			$taxonomies[$taxonomy] = wp_sprintf($t['template'], $links, $t['label']);
+	}
+	return $taxonomies;
+}
 ?>
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 7509)
+++ wp-includes/media.php	(working copy)
@@ -437,4 +437,35 @@
 		echo wp_get_attachment_link($attachments[$k]->ID, 'thumbnail', true);
 }
 
+function get_attachment_taxonomies($attachment) {
+	if ( is_int( $attachment ) )
+		$attachment = get_post($attachment);
+	else if ( is_array($attachment) )
+		$attachment = (object) $attachment;
+
+	if ( ! is_object($attachment) )
+		return array();
+
+	$filename = basename($attachment->guid);
+
+	$objects = array('attachment');
+
+	if ( false !== strpos($filename, '.') )
+		$objects[] = 'attachment:' . substr($filename, strrpos($filename, '.') + 1);
+	if ( !empty($attachment->post_mime_type) ) {
+		$objects[] = 'attachment:' . $attachment->post_mime_type;
+		if ( false !== strpos($attachment->post_mime_type, '/') )
+			foreach ( explode('/', $attachment->post_mime_type) as $token )
+				if ( !empty($token) )
+					$objects[] = "attachment:$token";
+	}
+
+	$taxonomies = array();
+	foreach ( $objects as $object )
+		if ( $taxes = get_object_taxonomies($object) )
+			$taxonomies = array_merge($taxonomies, $taxes);
+
+	return array_unique($taxonomies);
+}
+
 ?>
Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 7509)
+++ wp-includes/query.php	(working copy)
@@ -1147,7 +1147,7 @@
 				$term_ids[] = $term->term_id;
 			$post_ids = get_objects_in_term($term_ids, $q['taxonomy']);
 
-			if ( count($post_ids) ) {
+			if ( !is_wp_error($post_ids) && count($post_ids) ) {
 				$whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") ";
 				$post_type = 'any';
 				$q['post_status'] = 'publish';
@@ -1292,7 +1292,7 @@
 					$statuswheres[] = "(" . join( ' OR ', $p_status ) . ")";
 			}
 			if ( $post_status_join ) {
-				$join .= " INNER JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) ";
+				$join .= " LEFT JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) ";
 				foreach ( $statuswheres as $index => $statuswhere )
 					$statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))";
 			}
Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 7509)
+++ wp-includes/formatting.php	(working copy)
@@ -1376,7 +1376,7 @@
 	$args = (array) $args;
 	$result = array_shift($args);
 	if ( count($args) == 1 )
-		$result .= $l['between_two'] . array_shift($args);
+		$result .= $l['between_only_two'] . array_shift($args);
 	// Loop when more than two args
 	while ( count($args) ) {
 		$arg = array_shift($args);
Index: wp-includes/rewrite.php
===================================================================
--- wp-includes/rewrite.php	(revision 7509)
+++ wp-includes/rewrite.php	(working copy)
@@ -461,6 +461,12 @@
 		return $this->tag_structure;
 	}
 
+	function get_extra_permastruct($name) {
+		if ( isset($this->extra_permastructs[$name]) )
+			return $this->extra_permastructs[$name];
+		return false;
+	}
+
 	function get_author_permastruct() {
 		if (isset($this->author_structure)) {
 			return $this->author_structure;
@@ -832,15 +838,14 @@
 		$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
 
 		// Extra permastructs
-		$extra_rewrite = array();
 		foreach ( $this->extra_permastructs as $permastruct )
-			$extra_rewrite = array_merge($extra_rewrite, $this->generate_rewrite_rules($permastruct, EP_NONE));
+			$this->extra_rules_top = array_merge($this->extra_rules_top, $this->generate_rewrite_rules($permastruct, EP_NONE));
 
 		// Put them together.
 		if ( $this->use_verbose_page_rules )
-			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $extra_rewrite, $this->extra_rules);
+			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
 		else
-			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $extra_rewrite, $page_rewrite, $this->extra_rules);
+			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
 
 		do_action_ref_array('generate_rewrite_rules', array(&$this));
 		$this->rules = apply_filters('rewrite_rules_array', $this->rules);
@@ -954,10 +959,10 @@
 		$wp->add_query_var($name);
 	}
 
-	function add_permastruct($struct, $with_front = true) {
+	function add_permastruct($name, $struct, $with_front = true) {
 		if ( $with_front )
 			$struct = $this->front . $struct;
-		$this->extra_permastructs[] = $struct;
+		$this->extra_permastructs[$name] = $struct;
 	}
 
 	function flush_rules() {
Index: wp-content/themes/default/image.php
===================================================================
--- wp-content/themes/default/image.php	(revision 7509)
+++ wp-content/themes/default/image.php	(working copy)
@@ -23,6 +23,7 @@
 					<small>
 						This entry was posted on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?>
 						and is filed under <?php the_category(', ') ?>.
+						<?php the_taxonomies(); ?>
 						You can follow any responses to this entry through the <?php post_comments_feed_link('RSS 2.0'); ?> feed.
 
 						<?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php	(revision 7509)
+++ wp-admin/includes/media.php	(working copy)
@@ -426,37 +426,6 @@
 	return wp_iframe( 'media_upload_library_form', $errors );
 }
 
-function get_attachment_taxonomies($attachment) {
-	if ( is_int( $attachment ) )
-		$attachment = get_post($attachment);
-	else if ( is_array($attachment) )
-		$attachment = (object) $attachment;
-
-	if ( ! is_object($attachment) )
-		return array();
-
-	$filename = basename($attachment->guid);
-
-	$objects = array('attachment');
-
-	if ( false !== strpos($filename, '.') )
-		$objects[] = 'attachment:' . substr($filename, strrpos($filename, '.') + 1);
-	if ( !empty($attachment->post_mime_type) ) {
-		$objects[] = 'attachment:' . $attachment->post_mime_type;
-		if ( false !== strpos($attachment->post_mime_type, '/') )
-			foreach ( explode('/', $attachment->post_mime_type) as $token )
-				if ( !empty($token) )
-					$objects[] = "attachment:$token";
-	}
-
-	$taxonomies = array();
-	foreach ( $objects as $object )
-		if ( $taxes = get_object_taxonomies($object) )
-			$taxonomies = array_merge($taxonomies, $taxes);
-
-	return array_unique($taxonomies);
-}
-
 function image_attachment_fields_to_edit($form_fields, $post) {
 	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
 		$form_fields['post_title']['required'] = true;

