Make WordPress Core

Ticket #35084: 35084.5.diff

File 35084.5.diff, 1.3 KB (added by tharsheblows, 7 years ago)

only ignore parent if not in database (with docs this time)

  • src/wp-includes/post.php

     
    42864286 * Sub pages will be in the "directory" under the parent page post name.
    42874287 *
    42884288 * @since 1.5.0
     4289 * @since 4.4.0 Do not add parent slugs to orphaned pages
     4290 * @since 4.4.1 Do not add parent slugs when the parent does not exist
    42894291 *
    42904292 * @param WP_Post|object|int $page Page object or page ID.
    42914293 * @return string|false Page URI, false on error.
     
    43004302
    43014303        foreach ( $page->ancestors as $parent ) {
    43024304                $parent = get_post( $parent );
    4303                 if ( 'publish' === $parent->post_status ) {
     4305                if (!empty( $parent ) ) {
    43044306                        $uri = $parent->post_name . '/' . $uri;
    43054307                }
    43064308        }
  • 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