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.
- The topic ‘Cached objects can be modified’ is closed to new replies.