Make WordPress Core

Changeset 55741

Timestamp:
05/10/2023 09:09:06 AM (15 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.

Location:
trunk/tests/phpunit/includes
Files:
2 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        }
  • trunk/tests/phpunit/includes/object-cache.php

    r55581 r55741  
    326326    switch ( $feature ) {
    327327        case 'get_multiple':
     328
    328329            return true;
    329330        default:
    330331            return false;
    331332    }
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
    332343}
    333344
     
    14111422
    14121423        return $result;
     1424
     1425
     1426
     1427
     1428
     1429
     1430
     1431
     1432
     1433
     1434
    14131435    }
    14141436
Note: See TracChangeset for help on using the changeset viewer.