Make WordPress Core

Ticket #24612: 24612.patch

File 24612.patch, 1.2 KB (added by SergeyBiryukov, 10 years ago)
  • src/wp-includes/query.php

     
    16661666                }
    16671667
    16681668                if ( '' != $qv['pagename'] ) {
    1669                         $this->queried_object = get_page_by_path($qv['pagename']);
    1670                         if ( !empty($this->queried_object) )
     1669                        $this->queried_object = get_page_by_path( $qv['pagename'] );
     1670
     1671                        if ( $this->queried_object && 'attachment' == $this->queried_object->post_type ) {
     1672                                if ( preg_match( "/^[^%]*%(?:postname)%/", get_option( 'permalink_structure' ) ) ) {
     1673                                        // See if we also have a post with the same slug
     1674                                        $post = get_page_by_path( $qv['pagename'], OBJECT, 'post' );
     1675                                        if ( $post ) {
     1676                                                $this->queried_object = $post;
     1677                                                $this->is_page = false;
     1678                                        }
     1679                                }
     1680                        }
     1681
     1682                        if ( $this->queried_object )
    16711683                                $this->queried_object_id = (int) $this->queried_object->ID;
    16721684                        else
    1673                                 unset($this->queried_object);
     1685                                unset( $this->queried_object );
    16741686
    16751687                        if  ( 'page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts') ) {
    16761688                                $this->is_page = false;