Make WordPress Core

Ticket #46671: 46671.4.diff

File 46671.4.diff, 744 bytes (added by SergeyBiryukov, 4 years ago)
  • src/wp-admin/revision.php

     
    6060
    6161                check_admin_referer( "restore-post_{$revision->ID}" );
    6262
     63                /*
     64                 * Ensure the global $post remains the same after the revision is restored.
     65                 * Because wp_insert_post() and wp_transition_post_status() are called
     66                 * during the process, plugins can unexpectedly modify $post.
     67                 */
     68                $backup_global_post = clone $post;
     69
    6370                wp_restore_post_revision( $revision->ID );
    6471
     72                // Restore the global $post as it was before.
     73                $post = $backup_global_post;
     74
    6575                $redirect = add_query_arg(
    6676                        array(
    6777                                'message'  => 5,