Revisions: 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`. Props markparnell, tofandel, archon810, SergeyBiryukov. Fixes #46671. Built from https://develop.svn.wordpress.org/trunk@48625 git-svn-id: http://core.svn.wordpress.org/trunk@48387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a6cf8df9d1
commit
df74d8f10d
@ -60,8 +60,18 @@ switch ( $action ) {
|
|||||||
|
|
||||||
check_admin_referer( "restore-post_{$revision->ID}" );
|
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 );
|
wp_restore_post_revision( $revision->ID );
|
||||||
|
|
||||||
|
// Restore the global $post as it was before.
|
||||||
|
$post = $backup_global_post;
|
||||||
|
|
||||||
$redirect = add_query_arg(
|
$redirect = add_query_arg(
|
||||||
array(
|
array(
|
||||||
'message' => 5,
|
'message' => 5,
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user