diff --git a/wp-admin/revision.php b/wp-admin/revision.php index 43cc266748..156e998b57 100644 --- a/wp-admin/revision.php +++ b/wp-admin/revision.php @@ -60,8 +60,18 @@ switch ( $action ) { check_admin_referer( "restore-post_{$revision->ID}" ); + /* + * Ensure the global $post remains the same after revision is restored. + * Because wp_insert_post() and wp_transition_post_status() are called + * during the process, plugins can unexpectedly modify $post. + */ + $backup_global_post = clone $post; + wp_restore_post_revision( $revision->ID ); + // Restore the global $post as it was before. + $post = $backup_global_post; + $redirect = add_query_arg( array( 'message' => 5, diff --git a/wp-includes/version.php b/wp-includes/version.php index b92332110b..a7bb84c253 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-beta3-48624'; +$wp_version = '5.5-beta3-48625'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.