summaryrefslogtreecommitdiffstats
path: root/wp-includes/post.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-12-01 12:27:29 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-12-01 12:27:29 +0000
commitaae5b160f307adf0703ae8f7c2b158b91570ec95 (patch)
treeba0d1eee6e2eedfe3fd0a693d773162ab9dc8a67 /wp-includes/post.php
parent9415bbca12c01c39da58e0ed2c4e6b44ff833e5d (diff)
downloadwordpress-mu-aae5b160f307adf0703ae8f7c2b158b91570ec95.tar.gz
wordpress-mu-aae5b160f307adf0703ae8f7c2b158b91570ec95.tar.xz
wordpress-mu-aae5b160f307adf0703ae8f7c2b158b91570ec95.zip
WP Merge to 4578, except for script-loader
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@817 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/post.php')
-rw-r--r--wp-includes/post.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/wp-includes/post.php b/wp-includes/post.php
index de3ec95..5202c4c 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -1249,6 +1249,19 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
else
$post_name = sanitize_title($post_name);
+ $post_name_check =
+ $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'inherit' AND ID != '$post_ID' LIMIT 1");
+
+ if ($post_name_check) {
+ $suffix = 2;
+ while ($post_name_check) {
+ $alt_post_name = $post_name . "-$suffix";
+ $post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'inherit' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1");
+ $suffix++;
+ }
+ $post_name = $alt_post_name;
+ }
+
if (empty($post_date))
$post_date = current_time('mysql');
if (empty($post_date_gmt))