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:
Weston Ruter 2017-08-29 04:09:57 +00:00
parent a27cd850a2
commit 8e8969aa9c
2 changed files with 4 additions and 1 deletions

View File

@ -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;
}

View File

@ -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() ) );
}
/**