From e241ac664a133501aac3418e61b4b18d42cdf007 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 20 Sep 2022 04:31:09 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@54244 git-svn-id: http://core.svn.wordpress.org/trunk@53803 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/post.php | 3 ++- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 1abe542316..ff3c8d269a 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1399,6 +1399,7 @@ function get_sample_permalink( $post, $title = null, $name = null ) { $original_status = $post->post_status; $original_date = $post->post_date; $original_name = $post->post_name; + $original_filter = $post->filter; // Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published. if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ), true ) ) { @@ -1443,7 +1444,7 @@ function get_sample_permalink( $post, $title = null, $name = null ) { $post->post_status = $original_status; $post->post_date = $original_date; $post->post_name = $original_name; - unset( $post->filter ); + $post->filter = $original_filter; /** * Filters the sample permalink. diff --git a/wp-includes/version.php b/wp-includes/version.php index 85ef16d436..5d0b99b121 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-54243'; +$wp_version = '6.1-alpha-54244'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.