Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 11461)
+++ wp-includes/post.php	(working copy)
@@ -1394,6 +1394,7 @@
 	if ( !empty($ID) ) {
 		$update = true;
 		$previous_status = get_post_field('post_status', $ID);
+		$previous_slug = get_post_field('post_name', $ID);
 	} else {
 		$previous_status = 'new';
 	}
@@ -1513,7 +1514,10 @@
 	if ( !isset($post_password) || 'private' == $post_status )
 		$post_password = '';
 
-	$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
+	// If updating a published post, make slug unique only if it has changed.
+	// This prevents slugs for already published posts from being changed due to new uniqueness rules.
+	if ( !isset($previous_slug) || ('publish' != $previous_status) || ('publish' != $post_status) || ($previous_slug != $post_name))
+		$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
 
 	// expected_slashed (everything!)
 	$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) );
@@ -1736,29 +1740,27 @@
  * @param integer $post_parent
  * @return string unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
  */
-function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) {
+function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type = '', $post_parent = '') {
 	global $wpdb, $wp_rewrite;
-	if ( !in_array( $post_status, array( 'draft', 'pending' ) ) ) {
-		$hierarchical_post_types = apply_filters('hierarchical_post_types', array('page', 'attachment'));
-		if ( in_array($post_type, $hierarchical_post_types) ) {
-			$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode("', '", $wpdb->escape($hierarchical_post_types)) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
-			$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID, $post_parent));
-		} else {
-			$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1";
-			$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID, $post_parent));
-		}
 
-		if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) {
-			$suffix = 2;
-			do {
-				$alt_post_name = substr($slug, 0, 200-(strlen($suffix)+1)). "-$suffix";
-				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID, $post_parent));
-				$suffix++;
-			} while ($post_name_check);
-			$slug = $alt_post_name;
-		}
+	$original_slug = $slug;
+
+	if ( in_array( $post_status, array( 'draft', 'pending' ) ) )
+		return apply_filters('unique_post_slug', $slug, $original_slug, $post_ID, $post_status, $post_type, $post_parent);
+	
+	$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type != 'revision' AND post_status != 'draft' AND ID != %d LIMIT 1";
+	$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID));
+	if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) {
+		$suffix = 2;
+		do {
+			$alt_post_name = substr($slug, 0, 200-(strlen($suffix)+1)). "-$suffix";
+			$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_ID));
+			$suffix++;
+		} while ($post_name_check);
+		$slug = $alt_post_name;
 	}
-	return $slug;
+
+	return apply_filters('unique_post_slug', $slug, $original_slug, $post_ID, $post_status, $post_type, $post_parent);
 }
 
 /**
@@ -2452,20 +2454,8 @@
 	else
 		$post_name = sanitize_title($post_name);
 
-	// expected_slashed ($post_name)
-	$post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_status = 'inherit' AND ID != %d LIMIT 1", $post_name, $post_ID ) );
+	$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
 
-	if ( $post_name_check ) {
-		$suffix = 2;
-		while ( $post_name_check ) {
-			$alt_post_name = $post_name . "-$suffix";
-			// expected_slashed ($alt_post_name, $post_name)
-			$post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_status = 'inherit' AND ID != %d LIMIT 1", $alt_post_name, $post_ID ) );
-			$suffix++;
-		}
-		$post_name = $alt_post_name;
-	}
-
 	if ( empty($post_date) )
 		$post_date = current_time('mysql');
 	if ( empty($post_date_gmt) )
@@ -3776,4 +3766,4 @@
 
 		add_filter('the_preview', '_set_preview');
 	}
-}
+}
\ No newline at end of file
