Customize: Prevent potential cache corruption when finding a secondary changeset post by UUID.
Props dlh. Fixes #41738. git-svn-id: https://develop.svn.wordpress.org/trunk@41321 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a27cd850a2
commit
8e8969aa9c
@ -816,7 +816,7 @@ final class WP_Customize_Manager {
|
||||
if ( ! empty( $changeset_post_query->posts ) ) {
|
||||
// Note: 'fields'=>'ids' is not being used in order to cache the post object as it will be needed.
|
||||
$changeset_post_id = $changeset_post_query->posts[0]->ID;
|
||||
wp_cache_set( $this->_changeset_uuid, $changeset_post_id, $cache_group );
|
||||
wp_cache_set( $uuid, $changeset_post_id, $cache_group );
|
||||
return $changeset_post_id;
|
||||
}
|
||||
|
||||
|
@ -303,6 +303,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$wp_customize = new WP_Customize_Manager();
|
||||
$this->assertNull( $wp_customize->find_changeset_post_id( wp_generate_uuid4() ) );
|
||||
$this->assertEquals( $post_id, $wp_customize->find_changeset_post_id( $uuid ) );
|
||||
|
||||
// Verify that the found post ID was cached under the given UUID, not the manager's UUID.
|
||||
$this->assertNotEquals( $post_id, $wp_customize->find_changeset_post_id( $wp_customize->changeset_uuid() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user