Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
@ -81,7 +81,7 @@ function wp_cache_decr( $key, $offset = 1, $group = '' ) {
|
|||
function wp_cache_delete( $key, $group = '' ) {
|
||||
global $wp_object_cache;
|
||||
|
||||
return $wp_object_cache->delete($key, $group);
|
||||
return $wp_object_cache->delete( $key, $group );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,7 +115,7 @@ function wp_cache_flush() {
|
|||
* @param bool $found Optional. Whether the key was found in the cache (passed by reference).
|
||||
* Disambiguates a return of false, a storable value. Default null.
|
||||
* @return bool|mixed False on failure to retrieve contents or the cache
|
||||
* contents on success
|
||||
* contents on success
|
||||
*/
|
||||
function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
|
||||
global $wp_object_cache;
|
||||
|
@ -390,7 +390,7 @@ class WP_Object_Cache {
|
|||
*
|
||||
* @uses WP_Object_Cache::_exists() Checks to see if the cache already has data.
|
||||
* @uses WP_Object_Cache::set() Sets the data after the checking the cache
|
||||
* contents existence.
|
||||
* contents existence.
|
||||
*
|
||||
* @param int|string $key What to call the contents in the cache.
|
||||
* @param mixed $data The contents to store in the cache.
|
||||
|
@ -399,18 +399,22 @@ class WP_Object_Cache {
|
|||
* @return bool False if cache key and group already exist, true on success
|
||||
*/
|
||||
public function add( $key, $data, $group = 'default', $expire = 0 ) {
|
||||
if ( wp_suspend_cache_addition() )
|
||||
if ( wp_suspend_cache_addition() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $group ) )
|
||||
if ( empty( $group ) ) {
|
||||
$group = 'default';
|
||||
}
|
||||
|
||||
$id = $key;
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
|
||||
$id = $this->blog_prefix . $key;
|
||||
}
|
||||
|
||||
if ( $this->_exists( $id, $group ) )
|
||||
if ( $this->_exists( $id, $group ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->set( $key, $data, $group, (int) $expire );
|
||||
}
|
||||
|
@ -425,7 +429,7 @@ class WP_Object_Cache {
|
|||
public function add_global_groups( $groups ) {
|
||||
$groups = (array) $groups;
|
||||
|
||||
$groups = array_fill_keys( $groups, true );
|
||||
$groups = array_fill_keys( $groups, true );
|
||||
$this->global_groups = array_merge( $this->global_groups, $groups );
|
||||
}
|
||||
|
||||
|
@ -440,24 +444,29 @@ class WP_Object_Cache {
|
|||
* @return false|int False on failure, the item's new value on success.
|
||||
*/
|
||||
public function decr( $key, $offset = 1, $group = 'default' ) {
|
||||
if ( empty( $group ) )
|
||||
if ( empty( $group ) ) {
|
||||
$group = 'default';
|
||||
}
|
||||
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
|
||||
$key = $this->blog_prefix . $key;
|
||||
}
|
||||
|
||||
if ( ! $this->_exists( $key, $group ) )
|
||||
if ( ! $this->_exists( $key, $group ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
|
||||
if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) {
|
||||
$this->cache[ $group ][ $key ] = 0;
|
||||
}
|
||||
|
||||
$offset = (int) $offset;
|
||||
|
||||
$this->cache[ $group ][ $key ] -= $offset;
|
||||
|
||||
if ( $this->cache[ $group ][ $key ] < 0 )
|
||||
if ( $this->cache[ $group ][ $key ] < 0 ) {
|
||||
$this->cache[ $group ][ $key ] = 0;
|
||||
}
|
||||
|
||||
return $this->cache[ $group ][ $key ];
|
||||
}
|
||||
|
@ -475,16 +484,19 @@ class WP_Object_Cache {
|
|||
* @return bool False if the contents weren't deleted and true on success.
|
||||
*/
|
||||
public function delete( $key, $group = 'default', $deprecated = false ) {
|
||||
if ( empty( $group ) )
|
||||
if ( empty( $group ) ) {
|
||||
$group = 'default';
|
||||
}
|
||||
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
|
||||
$key = $this->blog_prefix . $key;
|
||||
}
|
||||
|
||||
if ( ! $this->_exists( $key, $group ) )
|
||||
if ( ! $this->_exists( $key, $group ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unset( $this->cache[$group][$key] );
|
||||
unset( $this->cache[ $group ][ $key ] );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -514,29 +526,32 @@ class WP_Object_Cache {
|
|||
*
|
||||
* @param int|string $key What the contents in the cache are called.
|
||||
* @param string $group Optional. Where the cache contents are grouped. Default 'default'.
|
||||
* @param string $force Optional. Unused. Whether to force a refetch rather than relying on the local
|
||||
* @param bool $force Optional. Unused. Whether to force a refetch rather than relying on the local
|
||||
* cache. Default false.
|
||||
* @param bool $found Optional. Whether the key was found in the cache (passed by reference).
|
||||
* Disambiguates a return of false, a storable value. Default null.
|
||||
* @param bool $found Optional. Whether the key was found in the cache (passed by reference).
|
||||
* Disambiguates a return of false, a storable value. Default null.
|
||||
* @return false|mixed False on failure to retrieve contents or the cache contents on success.
|
||||
*/
|
||||
public function get( $key, $group = 'default', $force = false, &$found = null ) {
|
||||
if ( empty( $group ) )
|
||||
if ( empty( $group ) ) {
|
||||
$group = 'default';
|
||||
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
|
||||
$key = $this->blog_prefix . $key;
|
||||
|
||||
if ( $this->_exists( $key, $group ) ) {
|
||||
$found = true;
|
||||
$this->cache_hits += 1;
|
||||
if ( is_object($this->cache[$group][$key]) )
|
||||
return clone $this->cache[$group][$key];
|
||||
else
|
||||
return $this->cache[$group][$key];
|
||||
}
|
||||
|
||||
$found = false;
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
|
||||
$key = $this->blog_prefix . $key;
|
||||
}
|
||||
|
||||
if ( $this->_exists( $key, $group ) ) {
|
||||
$found = true;
|
||||
$this->cache_hits += 1;
|
||||
if ( is_object( $this->cache[ $group ][ $key ] ) ) {
|
||||
return clone $this->cache[ $group ][ $key ];
|
||||
} else {
|
||||
return $this->cache[ $group ][ $key ];
|
||||
}
|
||||
}
|
||||
|
||||
$found = false;
|
||||
$this->cache_misses += 1;
|
||||
return false;
|
||||
}
|
||||
|
@ -552,24 +567,29 @@ class WP_Object_Cache {
|
|||
* @return false|int False on failure, the item's new value on success.
|
||||
*/
|
||||
public function incr( $key, $offset = 1, $group = 'default' ) {
|
||||
if ( empty( $group ) )
|
||||
if ( empty( $group ) ) {
|
||||
$group = 'default';
|
||||
}
|
||||
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
|
||||
$key = $this->blog_prefix . $key;
|
||||
}
|
||||
|
||||
if ( ! $this->_exists( $key, $group ) )
|
||||
if ( ! $this->_exists( $key, $group ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
|
||||
if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) {
|
||||
$this->cache[ $group ][ $key ] = 0;
|
||||
}
|
||||
|
||||
$offset = (int) $offset;
|
||||
|
||||
$this->cache[ $group ][ $key ] += $offset;
|
||||
|
||||
if ( $this->cache[ $group ][ $key ] < 0 )
|
||||
if ( $this->cache[ $group ][ $key ] < 0 ) {
|
||||
$this->cache[ $group ][ $key ] = 0;
|
||||
}
|
||||
|
||||
return $this->cache[ $group ][ $key ];
|
||||
}
|
||||
|
@ -588,15 +608,18 @@ class WP_Object_Cache {
|
|||
* @return bool False if not exists, true if contents were replaced.
|
||||
*/
|
||||
public function replace( $key, $data, $group = 'default', $expire = 0 ) {
|
||||
if ( empty( $group ) )
|
||||
if ( empty( $group ) ) {
|
||||
$group = 'default';
|
||||
}
|
||||
|
||||
$id = $key;
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
|
||||
$id = $this->blog_prefix . $key;
|
||||
}
|
||||
|
||||
if ( ! $this->_exists( $id, $group ) )
|
||||
if ( ! $this->_exists( $id, $group ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->set( $key, $data, $group, (int) $expire );
|
||||
}
|
||||
|
@ -614,8 +637,9 @@ class WP_Object_Cache {
|
|||
|
||||
// Clear out non-global caches since the blog ID has changed.
|
||||
foreach ( array_keys( $this->cache ) as $group ) {
|
||||
if ( ! isset( $this->global_groups[ $group ] ) )
|
||||
if ( ! isset( $this->global_groups[ $group ] ) ) {
|
||||
unset( $this->cache[ $group ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,16 +664,19 @@ class WP_Object_Cache {
|
|||
* @return true Always returns true.
|
||||
*/
|
||||
public function set( $key, $data, $group = 'default', $expire = 0 ) {
|
||||
if ( empty( $group ) )
|
||||
if ( empty( $group ) ) {
|
||||
$group = 'default';
|
||||
}
|
||||
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
|
||||
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
|
||||
$key = $this->blog_prefix . $key;
|
||||
}
|
||||
|
||||
if ( is_object( $data ) )
|
||||
if ( is_object( $data ) ) {
|
||||
$data = clone $data;
|
||||
}
|
||||
|
||||
$this->cache[$group][$key] = $data;
|
||||
$this->cache[ $group ][ $key ] = $data;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -662,12 +689,12 @@ class WP_Object_Cache {
|
|||
* @since 2.0.0
|
||||
*/
|
||||
public function stats() {
|
||||
echo "<p>";
|
||||
echo '<p>';
|
||||
echo "<strong>Cache Hits:</strong> {$this->cache_hits}<br />";
|
||||
echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br />";
|
||||
echo "</p>";
|
||||
echo '</p>';
|
||||
echo '<ul>';
|
||||
foreach ($this->cache as $group => $cache) {
|
||||
foreach ( $this->cache as $group => $cache ) {
|
||||
echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
|
@ -683,7 +710,7 @@ class WP_Object_Cache {
|
|||
* @param int $blog_id Blog ID.
|
||||
*/
|
||||
public function switch_to_blog( $blog_id ) {
|
||||
$blog_id = (int) $blog_id;
|
||||
$blog_id = (int) $blog_id;
|
||||
$this->blog_prefix = $this->multisite ? $blog_id . ':' : '';
|
||||
}
|
||||
|
||||
|
@ -706,9 +733,8 @@ class WP_Object_Cache {
|
|||
* @since 2.0.8
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->multisite = is_multisite();
|
||||
$this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : '';
|
||||
|
||||
$this->multisite = is_multisite();
|
||||
$this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : '';
|
||||
|
||||
/**
|
||||
* @todo This should be moved to the PHP4 style constructor, PHP5
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue