Make WordPress Core

Changeset 54244

Timestamp:
09/20/2022 04:29:11 AM (23 months ago)
Author:
peterwilsoncc
Message:

Posts, Post types: Prevent get_sample_permalink() modifying the post object.

get_sample_permalink() (ab)uses the $post->filter property to indicate a sample permalink is being generated for the post. This change ensures the property is restored to its original value.

Props herregroen, hellofromTonya, peterwilsoncc, Rahmohn, costdev.
Fixes #54736.

Location:
trunk
Files:
2 edited

Legend:

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

    r54122 r54244  
    14001400    $original_date   = $post->post_date;
    14011401    $original_name   = $post->post_name;
     1402
    14021403
    14031404    // Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published.
     
    14441445    $post->post_date   = $original_date;
    14451446    $post->post_name   = $original_name;
    1446     unset( $post->filter );
     1447    ;
    14471448
    14481449    /**
  • trunk/tests/phpunit/tests/admin/includesPost.php

    r54122 r54244  
    685685        $this->assertSame( home_url() . '/parent-page/%pagename%/', $actual[0] );
    686686        $this->assertSame( 'child-page', $actual[1] );
     687
     688
     689
     690
     691
     692
     693
     694
     695
     696
     697
     698
     699
     700
     701
     702
     703
     704
     705
     706
     707
     708
     709
     710
     711
     712
     713
     714
     715
     716
    687717    }
    688718
Note: See TracChangeset for help on using the changeset viewer.