mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-31 21:48:36 +01:00
Customize: Ensure customize_autosaved
requests only use revision of logged-in user.
Props dlh, westonruter. See #42433, #39896. Merges [42615] to the 4.9 branch. Fixes #42450. Built from https://develop.svn.wordpress.org/branches/4.9@42620 git-svn-id: http://core.svn.wordpress.org/branches/4.9@42449 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d7291a5435
commit
a271c43cdb
@ -1135,7 +1135,7 @@ final class WP_Customize_Manager {
|
||||
if ( ! $changeset_post_id ) {
|
||||
$this->_changeset_data = array();
|
||||
} else {
|
||||
if ( $this->autosaved() ) {
|
||||
if ( $this->autosaved() && is_user_logged_in() ) {
|
||||
$autosave_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
|
||||
if ( $autosave_post ) {
|
||||
$data = $this->get_changeset_post_data( $autosave_post->ID );
|
||||
@ -2878,10 +2878,12 @@ final class WP_Customize_Manager {
|
||||
$post_array['edit_date'] = true; // Prevent date clearing.
|
||||
$r = wp_update_post( wp_slash( $post_array ), true );
|
||||
|
||||
// Delete autosave revision when the changeset is updated.
|
||||
$autosave_draft = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
|
||||
if ( $autosave_draft ) {
|
||||
wp_delete_post( $autosave_draft->ID, true );
|
||||
// Delete autosave revision for user when the changeset is updated.
|
||||
if ( ! empty( $args['user_id'] ) ) {
|
||||
$autosave_draft = wp_get_post_autosave( $changeset_post_id, $args['user_id'] );
|
||||
if ( $autosave_draft ) {
|
||||
wp_delete_post( $autosave_draft->ID, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -3493,6 +3495,11 @@ final class WP_Customize_Manager {
|
||||
* @since 4.9.0
|
||||
*/
|
||||
public function handle_dismiss_autosave_or_lock_request() {
|
||||
// Calls to dismiss_user_auto_draft_changesets() and wp_get_post_autosave() require non-zero get_current_user_id().
|
||||
if ( ! is_user_logged_in() ) {
|
||||
wp_send_json_error( 'unauthenticated', 401 );
|
||||
}
|
||||
|
||||
if ( ! $this->is_preview() ) {
|
||||
wp_send_json_error( 'not_preview', 400 );
|
||||
}
|
||||
@ -4574,7 +4581,9 @@ final class WP_Customize_Manager {
|
||||
$changeset_post_id = $this->changeset_post_id();
|
||||
if ( ! $this->saved_starter_content_changeset && ! $this->autosaved() ) {
|
||||
if ( $changeset_post_id ) {
|
||||
$autosave_revision_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
|
||||
if ( is_user_logged_in() ) {
|
||||
$autosave_revision_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
|
||||
}
|
||||
} else {
|
||||
$autosave_autodraft_posts = $this->get_changeset_posts( array(
|
||||
'posts_per_page' => 1,
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9.3-beta1-42609';
|
||||
$wp_version = '4.9.3-beta1-42620';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user