mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Editor: Refresh nones for metaboxes after reauthentication.
This fixes an issue where metaboxes fail to save after a session expires and a user logs in again via the heartbeat API. Props LinSoftware. Fixes #52584. git-svn-id: https://develop.svn.wordpress.org/trunk@54122 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1016,4 +1016,42 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
|
||||
$this->assertSame( 0, post_exists( $title, null, null, $post_type, 'draft' ) );
|
||||
$this->assertSame( 0, post_exists( $title, null, null, 'wp_tests', $post_status ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test refreshed nonce for metabox loader.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_user_get_refreshed_metabox_nonce() {
|
||||
|
||||
// Create a post by the current user.
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
$post_data = array(
|
||||
'post_content' => 'Test post content',
|
||||
'post_title' => 'Test post title',
|
||||
'post_excerpt' => 'Test post excerpt',
|
||||
'post_author' => self::$editor_id,
|
||||
'post_status' => 'draft',
|
||||
);
|
||||
$post_id = wp_insert_post( $post_data );
|
||||
|
||||
// Simulate the $_POST data from the heartbeat.
|
||||
$data = array(
|
||||
'wp-refresh-metabox-loader-nonces' => array(
|
||||
'post_id' => (string) $post_id,
|
||||
),
|
||||
'wp-refresh-post-lock' => array(
|
||||
'lock' => '1658203298:1',
|
||||
'post_id' => (string) $post_id,
|
||||
),
|
||||
);
|
||||
|
||||
// Call the function we're testing.
|
||||
$response = wp_refresh_metabox_loader_nonces( array(), $data );
|
||||
|
||||
// Ensure that both nonces were created.
|
||||
$this->assertNotEmpty( $response['wp-refresh-metabox-loader-nonces']['replace']['_wpnonce'] );
|
||||
$this->assertNotEmpty( $response['wp-refresh-metabox-loader-nonces']['replace']['metabox_loader_nonce'] );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user