WordPress.org

Make WordPress Core

Ticket #35084: 35084.4.diff

File 35084.4.diff, 977 bytes (added by tharsheblows, 4 years ago)

only ignore parent in permalink if it is not in database

  • src/wp-includes/post.php

     
    43004300
    43014301        foreach ( $page->ancestors as $parent ) {
    43024302                $parent = get_post( $parent );
    4303                 if ( 'publish' === $parent->post_status ) {
     4303                if (!empty( $parent ) ) {
    43044304                        $uri = $parent->post_name . '/' . $uri;
    43054305                }
    43064306        }
  • tests/phpunit/tests/post.php

     
    674674                // try the child normally
    675675                $this->assertEquals( 'parent/child', get_page_uri( $child_id ) );
    676676
    677                 // now delete the parent and check
    678                 wp_delete_post( $parent_id );
     677                // now delete the parent from the database and check
     678                wp_delete_post( $parent_id, true );
    679679                $this->assertEquals( 'child', get_page_uri( $child_id ) );
    680680        }
    681681