/**
* Adds data to the cache, if the cache key doesn't aleady exist.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::add()
*
* does not mean that plugins can't implement this function when they need to
* make sure that the cache is cleaned up after WordPress no longer needs it.
*
- * @since 2.0
+ * @since 2.0.0
*
* @return bool Always returns True
*/
/**
* Removes the cache contents matching ID and flag.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::delete()
*
/**
* Removes all cache items.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::flush()
*
/**
* Retrieves the cache contents from the cache by ID and flag.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::get()
*
/**
* Sets up Object Cache Global and assigns it.
*
- * @since 2.0
+ * @since 2.0.0
* @global WP_Object_Cache $wp_object_cache WordPress Object Cache
*/
function wp_cache_init() {
/**
* Replaces the contents of the cache with new data.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::replace()
*
/**
* Adds a group or set of groups to the list of global groups.
*
- * @since 2.6
+ * @since 2.6.0
*
* @param string|array $groups A group or an array of groups to add
*/
/**
* Adds a group or set of groups to the list of non-persistent groups.
*
- * @since 2.6
+ * @since 2.6.0
*
* @param string|array $groups A group or an array of groups to add
*/
*
* @var array
* @access private
- * @since 2.0
+ * @since 2.0.0
*/
var $cache = array ();
*
* @var array
* @access private
- * @since 2.0
+ * @since 2.0.0
*/
var $non_existant_objects = array ();
/**
* The amount of times the cache data was already stored in the cache.
*
- * @since 2.5
+ * @since 2.5.0
* @access private
* @var int
*/
*
* @var int
* @access public
- * @since 2.0
+ * @since 2.0.0
*/
var $cache_misses = 0;
* @uses WP_Object_Cache::set Sets the data after the checking the cache
* contents existance.
*
- * @since 2.0
+ * @since 2.0.0
*
* @param int|string $id What to call the contents in the cache
* @param mixed $data The contents to store in the cache
* to false, then nothing will happen. The $force parameter is set to false
* by default.
*
- * On success the group and the id will be added to the
+ * On success the group and the id will be added to the
* $non_existant_objects property in the class.
*
- * @since 2.0
+ * @since 2.0.0
*
* @param int|string $id What the contents in the cache are called
* @param string $group Where the cache contents are grouped
/**
* Clears the object cache of all data
*
- * @since 2.0
+ * @since 2.0.0
*
* @return bool Always returns true
*/
* misses will be incremented and the cache group and ID will be added to
* the nonexistant objects.
*
- * @since 2.0
+ * @since 2.0.0
*
* @param int|string $id What the contents in the cache are called
* @param string $group Where the cache contents are grouped
if (isset ($this->cache[$group][$id])) {
$this->cache_hits += 1;
- return $this->cache[$group][$id];
+ if ( is_object($this->cache[$group][$id]) )
+ return wp_clone($this->cache[$group][$id]);
+ else
+ return $this->cache[$group][$id];
}
if ( isset ($this->non_existant_objects[$group][$id]) )
/**
* Replace the contents in the cache, if contents already exist
*
- * @since 2.0
+ * @since 2.0.0
* @see WP_Object_Cache::set()
*
* @param int|string $id What to call the contents in the cache
* expire for each time a page is accessed and PHP finishes. The method is
* more for cache plugins which use files.
*
- * @since 2.0
+ * @since 2.0.0
*
* @param int|string $id What to call the contents in the cache
* @param mixed $data The contents to store in the cache
if (NULL === $data)
$data = '';
+ if ( is_object($data) )
+ $data = wp_clone($data);
+
$this->cache[$group][$id] = $data;
if(isset($this->non_existant_objects[$group][$id]))
* Gives the cache hits, and cache misses. Also prints every cached group,
* key and the data.
*
- * @since 2.0
+ * @since 2.0.0
*/
function stats() {
echo "<p>";
/**
* PHP4 constructor; Calls PHP 5 style constructor
*
- * @since 2.0
+ * @since 2.0.0
*
* @return WP_Object_Cache
*/