WordPress.org

Make WordPress Core

Changeset 21845


Ignore:
Timestamp:
09/14/2012 05:19:25 PM (6 years ago)
Author:
nacin
Message:

In get_page_by_path(), attempt to return an item that has the same post type before returning an attachment with the same name. props SergeyBiryukov. tests in [UT1021]. fixes #15665.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r21844 r21845  
    33073307    $post_type_sql = $post_type;
    33083308    $wpdb->escape_by_ref( $post_type_sql );
    3309     $pages = $wpdb->get_results( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name IN ($in_string) AND (post_type = '$post_type_sql' OR post_type = 'attachment')", OBJECT_K );
     3309    $pages = $wpdb->get_results( "SELECT ID, post_name, post_parent, post_type FROM $wpdb->posts WHERE post_name IN ($in_string) AND (post_type = '$post_type_sql' OR post_type = 'attachment')", OBJECT_K );
    33103310
    33113311    $revparts = array_reverse( $parts );
     
    33263326            if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->post_name == $revparts[ $count ] ) {
    33273327                $foundid = $page->ID;
    3328                 break;
     3328                if ( $page->post_type == $post_type )
     3329                    break;
    33293330            }
    33303331        }
Note: See TracChangeset for help on using the changeset viewer.