diff --git a/src/wp-includes/cache-compat.php b/src/wp-includes/cache-compat.php index 98f489931e..a9408ca611 100644 --- a/src/wp-includes/cache-compat.php +++ b/src/wp-includes/cache-compat.php @@ -123,3 +123,21 @@ if ( ! function_exists( 'wp_cache_delete_multiple' ) ) : return $values; } endif; + +if ( ! function_exists( 'wp_cache_flush_runtime' ) ) : + /** + * Removes all cache items from the in-memory runtime cache. + * + * Compat function to mimic wp_cache_flush_runtime(). + * + * @ignore + * @since 6.0.0 + * + * @see wp_cache_flush_runtime() + * + * @return bool True on success, false on failure. + */ + function wp_cache_flush_runtime() { + return wp_using_ext_object_cache() ? false : wp_cache_flush(); + } +endif; diff --git a/src/wp-includes/cache.php b/src/wp-includes/cache.php index b7e88efbd0..2a2a98f6d3 100644 --- a/src/wp-includes/cache.php +++ b/src/wp-includes/cache.php @@ -268,6 +268,19 @@ function wp_cache_flush() { return $wp_object_cache->flush(); } +/** + * Removes all cache items from the in-memory runtime cache. + * + * @since 6.0.0 + * + * @see WP_Object_Cache::flush() + * + * @return bool True on success, false on failure. + */ +function wp_cache_flush_runtime() { + return wp_cache_flush(); +} + /** * Closes the cache. * diff --git a/tests/phpunit/tests/pluggable.php b/tests/phpunit/tests/pluggable.php index a1dbda3506..c7b0225987 100644 --- a/tests/phpunit/tests/pluggable.php +++ b/tests/phpunit/tests/pluggable.php @@ -326,6 +326,7 @@ class Tests_Pluggable extends WP_UnitTestCase { 'group' => '', ), 'wp_cache_flush' => array(), + 'wp_cache_flush_runtime' => array(), 'wp_cache_close' => array(), 'wp_cache_add_global_groups' => array( 'groups' ), 'wp_cache_add_non_persistent_groups' => array( 'groups' ),