Changeset 33262
- Timestamp:
- 07/14/2015 12:27:11 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r33261 r33262 3817 3817 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 3818 3818 3819 // Prevent post slugs that could result in URLs that conflict with date archives. 3819 // Prevent new post slugs that could result in URLs that conflict with date archives. 3820 $post = get_post( $post_ID ); 3820 3821 $conflicts_with_date_archive = false; 3821 if ( 'post' === $post_type && preg_match( '/^[0-9]+$/', $slug ) && $slug_num = intval( $slug ) ) {3822 if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) && $slug_num = intval( $slug ) ) { 3822 3823 $permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) ); 3823 3824 $postname_index = array_search( '%postname%', $permastructs ); -
trunk/tests/phpunit/tests/post/wpUniquePostSlug.php
r32647 r33262 190 190 * @ticket 5305 191 191 */ 192 public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_not_be_suffixed_for_already_published_posts() { 193 global $wp_rewrite; 194 $wp_rewrite->init(); 195 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 196 $wp_rewrite->flush_rules(); 197 198 $p = $this->factory->post->create( array( 199 'post_type' => 'post', 200 'post_name' => 'foo', 201 'post_status' => 'publish', 202 ) ); 203 204 $found = wp_unique_post_slug( '2015', $p, 'publish', 'post', 0 ); 205 $this->assertEquals( '2015-2', $found ); 206 207 $wp_rewrite->set_permalink_structure( '' ); 208 flush_rewrite_rules(); 209 } 210 211 /** 212 * @ticket 5305 213 */ 192 214 public function test_yearlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_year_archives() { 193 215 global $wp_rewrite;
Note: See TracChangeset
for help on using the changeset viewer.