Ticket #32537: 32537.patch
File 32537.patch, 2.1 KB (added by , 9 years ago) |
---|
-
src/wp-includes/post.php
3435 3435 } 3436 3436 3437 3437 if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) { 3438 $data['post_name'] = sanitize_title( $data['post_title'], $post_ID ); 3438 if ( strlen($data['post_title']) ) { 3439 $data['post_name'] = sanitize_title( $data['post_title'], $post_ID ); 3440 } else { 3441 $data['post_name'] = wp_unique_post_slug( $post_ID, $post_ID, $data['post_status'], $data['post_type'], $data['post_parent'] ); 3442 } 3443 3439 3444 $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); 3440 3445 } 3441 3446 … … 3803 3808 // Prevent post slugs that could result in URLs that conflict with date archives. 3804 3809 $conflicts_with_date_archive = false; 3805 3810 if ( 'post' === $post_type && preg_match( '/^[0-9]+$/', $slug ) && $slug_num = intval( $slug ) ) { 3811 3806 3812 $permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) ); 3807 3813 $postname_index = array_search( '%postname%', $permastructs ); 3808 3814 -
tests/phpunit/tests/post.php
950 950 $this->assertEquals( $value, $post->$field ); 951 951 } 952 952 } 953 954 /** 955 * @ticket 32537 956 */ 957 function test_post_slug_with_content_without_title() { 958 global $wp_rewrite; 959 960 $wp_rewrite->init(); 961 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 962 $wp_rewrite->flush_rules(); 963 964 $postdata = array( 965 'post_status' => 'publish', 966 'post_content' => rand_str(), 967 'post_title' => '', 968 'post_type' => 'post', 969 ); 970 $post_id = wp_insert_post( $postdata ); 971 972 $post_object = get_post( $post_id ); 973 $unique_slug = wp_unique_post_slug( $post_object->post_name, $post_id, $post_object->post_status, $post_object->post_type, $post_object->post_parent ); 974 975 $this->assertEquals( $unique_slug, $post_object->post_name ); 976 } 953 977 }