Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions tests/phpunit/includes/abstract-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,9 @@ protected function _restore_hooks() {
public static function flush_cache() {
global $wp_object_cache;

$wp_object_cache->group_ops = array();
$wp_object_cache->stats = array();
$wp_object_cache->memcache_debug = array();
Comment on lines -390 to -392
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three properties are not used for anything. I have removed them for now.

$wp_object_cache->cache = array();
wp_cache_flush_runtime();

if ( method_exists( $wp_object_cache, '__remoteset' ) ) {
if ( is_object( $wp_object_cache ) && method_exists( $wp_object_cache, '__remoteset' ) ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all object caches use this global. Check it is object before running this.

$wp_object_cache->__remoteset();
}

Expand Down
22 changes: 22 additions & 0 deletions tests/phpunit/includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,23 @@ function wp_cache_flush( $delay = 0 ) {
function wp_cache_supports( $feature ) {
switch ( $feature ) {
case 'get_multiple':
case 'flush_runtime':
return true;
default:
return false;
}
}

/**
* Removes all cache items from the in-memory runtime cache.
*
* @return bool True on success, false on failure.
*/
function wp_cache_flush_runtime() {
global $wp_object_cache;
return $wp_object_cache->flush_runtime();
}

/**
* Retrieves object from cache.
*
Expand Down Expand Up @@ -1412,6 +1423,17 @@ public function flush( $delay = 0 ) {
return $result;
}

/**
* Clears the in-memory cache of all data leaving the external cache untouched.
*
* @return bool Always returns true.
*/
public function flush_runtime() {
$this->cache = array();

return true;
}

/**
* Retrieves object from cache.
*
Expand Down