Make sure post titles longer than 200 chars get unique slugs. fixes #4433. props AaronCampbell.

git-svn-id: http://svn.automattic.com/wordpress/trunk@5685 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2007-06-12 20:49:40 +00:00
parent 56272d8507
commit cf2b700d93

View File

@ -606,7 +606,7 @@ function wp_insert_post($postarr = array()) {
if ($post_name_check || in_array($post_name, $wp_rewrite->feeds) ) {
$suffix = 2;
do {
$alt_post_name = $post_name . "-$suffix";
$alt_post_name = substr($post_name, 0, 200-(strlen($suffix)+1)). "-$suffix";
$post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_type = '$post_type' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1");
$suffix++;
} while ($post_name_check);