Make WordPress Core


Ignore:
Timestamp:
05/10/2023 09:09:06 AM (16 months ago)
Author:
spacedmonkey
Message:

Build/Test Tools: Call wp_cache_flush_runtime in WP_UnitTestCase.

In WP_UnitTestCase::flush_cache method, the properties of the global $wp_object_cache object were manaully being reset to flush the cache. The function wp_cache_flush_runtime was added in [52772] and is designed to reset any class properties to default values. Using wp_cache_flush_runtime improve compatibility with third party object caches, as it allows developers to define their own wp_cache_flush_runtime function.

Props rmccue, johnbillion, wonderboymusic, boonebgorges, voldemortensen, dd32, DrewAPicture, tillkruess, spacedmonkey.
Fixes #31463.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r55680 r55741  
    388388        global $wp_object_cache;
    389389
    390         $wp_object_cache->group_ops      = array();
    391         $wp_object_cache->stats          = array();
    392         $wp_object_cache->memcache_debug = array();
    393         $wp_object_cache->cache          = array();
    394 
    395         if ( method_exists( $wp_object_cache, '__remoteset' ) ) {
     390        wp_cache_flush_runtime();
     391
     392        if ( is_object( $wp_object_cache ) && method_exists( $wp_object_cache, '__remoteset' ) ) {
    396393            $wp_object_cache->__remoteset();
    397394        }
Note: See TracChangeset for help on using the changeset viewer.