Changeset 30629
- Timestamp:
- 11/30/2014 04:48:54 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r30545 r30629 3704 3704 * namespace than posts so page slugs are allowed to overlap post slugs. 3705 3705 */ 3706 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %sAND ID != %d AND post_parent = %d LIMIT 1";3706 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1"; 3707 3707 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) ); 3708 3708 -
trunk/tests/phpunit/tests/post.php
r30529 r30629 505 505 */ 506 506 function test_get_page_by_path_priority() { 507 global $wpdb; 508 507 509 $attachment = $this->factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) ); 508 510 $page = $this->factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) ); 509 511 $other_att = $this->factory->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) ); 512 513 $wpdb->update( $wpdb->posts, array( 'post_name' => 'some-page' ), array( 'ID' => $page->ID ) ); 514 clean_post_cache( $page->ID ); 515 516 $page = get_post( $page->ID ); 510 517 511 518 $this->assertEquals( 'some-page', $attachment->post_name ); … … 989 996 990 997 /** 998 * @ticket 18962 999 */ 1000 function test_wp_unique_post_slug_with_hierarchy_and_attachments() { 1001 register_post_type( 'post-type-1', array( 'hierarchical' => true ) ); 1002 1003 $args = array( 1004 'post_type' => 'post-type-1', 1005 'post_name' => 'some-slug', 1006 'post_status' => 'publish', 1007 ); 1008 $one = $this->factory->post->create( $args ); 1009 1010 $args = array( 1011 'post_mime_type' => 'image/jpeg', 1012 'post_type' => 'attachment', 1013 'post_name' => 'image' 1014 ); 1015 $attachment = $this->factory->attachment->create_object( 'image.jpg', $one, $args ); 1016 1017 $args = array( 1018 'post_type' => 'post-type-1', 1019 'post_name' => 'image', 1020 'post_status' => 'publish', 1021 'post_parent' => $one 1022 ); 1023 $two = $this->factory->post->create( $args ); 1024 1025 $this->assertEquals( 'some-slug', get_post( $one )->post_name ); 1026 $this->assertEquals( 'image', get_post( $attachment )->post_name ); 1027 $this->assertEquals( 'image-2', get_post( $two )->post_name ); 1028 1029 // 'image' can be a child of image-2 1030 $this->assertEquals( 'image', wp_unique_post_slug( 'image', 0, 'publish', 'post-type-1', $two ) ); 1031 1032 _unregister_post_type( 'post-type-1' ); 1033 } 1034 1035 /** 991 1036 * @ticket 21212 992 1037 */
Note: See TracChangeset
for help on using the changeset viewer.