Title: Cached objects can be modified
Last modified: August 21, 2016

---

# Cached objects can be modified

 *  [Ben Doherty (Oomph, Inc)](https://wordpress.org/support/users/bendoh/)
 * (@bendoh)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/cached-objects-can-be-modified/)
 * Objects stored in the cache can be modified after they are pulled out using W3_ObjectCache-
   >get().
 * If the cached value is an object, once its value is determined to be in the cache,
   it is cloned (W3/ObjectCache.php:181), but that cloned value is then assigned
   back to the cache and returned.
 * Thus any modification to the returned object affects the value in the cache, 
   too, and the next call to get() returns the modified object.
 * The solution is to make another clone of the object for what is returned by the
   get() method, separately from the clone of the object stored in the cache.
 * [https://wordpress.org/plugins/w3-total-cache/](https://wordpress.org/plugins/w3-total-cache/)

The topic ‘Cached objects can be modified’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

## Tags

 * [modified](https://wordpress.org/support/topic-tag/modified/)
 * [object](https://wordpress.org/support/topic-tag/object/)

 * 0 replies
 * 1 participant
 * Last reply from: [Ben Doherty (Oomph, Inc)](https://wordpress.org/support/users/bendoh/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/cached-objects-can-be-modified/)
 * Status: not resolved