Changeset 53767
- Timestamp:
- 07/23/2022 02:56:51 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/cache-compat.php
r53763 r53767 146 146 /** 147 147 * Removes all cache items in a group, if the object cache implementation supports it. 148 * Before calling this method, always check for group flushing support using the 149 * `wp_cache_supports_group_flush()` method. 148 * 149 * Before calling this function, always check for group flushing support using the 150 * `wp_cache_supports_group_flush()` function. 150 151 * 151 152 * @since 6.1.0 … … 176 177 if ( ! function_exists( 'wp_cache_supports_group_flush' ) ) : 177 178 /** 178 * Whether the object cache implementation supports flushing individual cache groups.179 * hether the object cache implementation supports flushing individual cache groups. 179 180 * 180 181 * @since 6.1.0 -
trunk/src/wp-includes/cache.php
r53763 r53767 21 21 function wp_cache_init() { 22 22 $GLOBALS['wp_object_cache'] = new WP_Object_Cache(); 23 }24 25 /**26 * Whether the object cache implementation supports flushing individual cache groups.27 *28 * @since 6.1.029 *30 * @see WP_Object_Cache::flush_group()31 *32 * @return bool True if group flushing is supported, false otherwise.33 */34 function wp_cache_supports_group_flush() {35 return true;36 23 } 37 24 … … 297 284 /** 298 285 * Removes all cache items in a group, if the object cache implementation supports it. 299 * Before calling this method, always check for group flushing support using the 300 * `wp_cache_supports_group_flush()` method. 286 * 287 * Before calling this function, always check for group flushing support using the 288 * `wp_cache_supports_group_flush()` function. 301 289 * 302 290 * @since 6.1.0 … … 312 300 313 301 return $wp_object_cache->flush_group( $group ); 302 303 304 305 306 307 308 309 310 311 312 313 314 314 315 } 315 316 -
trunk/src/wp-includes/class-wp-object-cache.php
r53763 r53767 292 292 293 293 /** 294 * Removes all cache items in a group.295 *296 * @since 6.1.0297 *298 * @param string $group Name of group to remove from cache.299 * @return true Always returns true.300 */301 public function flush_group( $group ) {302 unset( $this->cache[ $group ] );303 304 return true;305 }306 307 /**308 294 * Retrieves the cache contents, if it exists. 309 295 * … … 511 497 512 498 /** 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 513 * Sets the list of global cache groups. 514 514 * -
trunk/tests/phpunit/includes/object-cache.php
r53763 r53767 283 283 global $wp_object_cache; 284 284 return $wp_object_cache->flush( $delay ); 285 286 287 288 289 290 291 292 293 294 295 285 296 } 286 297 … … 744 755 global $wp_object_cache; 745 756 $wp_object_cache = new WP_Object_Cache(); 746 }747 748 /**749 * Whether the object cache implementation supports flushing individual cache groups.750 *751 * @since 6.1.0752 *753 * @return bool True if group flushing is supported, false otherwise.754 */755 function wp_cache_supports_group_flush() {756 return false;757 757 } 758 758 -
trunk/tests/phpunit/tests/cache.php
r53763 r53767 128 128 // If there is no value get returns false. 129 129 $this->assertFalse( $this->cache->get( $key ) ); 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 130 160 } 131 161 … … 416 446 $this->assertSame( $expected, $found ); 417 447 } 418 419 /**420 * @ticket 4476421 * @ticket 9773422 *423 * test wp_cache_flush_group424 *425 * @covers ::wp_cache_flush_group426 */427 public function test_wp_cache_flush_group() {428 $key = 'my-key';429 $val = 'my-val';430 431 wp_cache_set( $key, $val, 'group-test' );432 wp_cache_set( $key, $val, 'group-kept' );433 434 $this->assertSame( $val, wp_cache_get( $key, 'group-test' ), 'test_wp_cache_flush_group: group-test should contain my-val' );435 436 if ( wp_using_ext_object_cache() ) {437 $this->setExpectedIncorrectUsage( 'wp_cache_flush_group' );438 }439 440 $results = wp_cache_flush_group( 'group-test' );441 442 if ( wp_using_ext_object_cache() ) {443 $this->assertFalse( $results );444 } else {445 $this->assertTrue( $results );446 $this->assertFalse( wp_cache_get( $key, 'group-test' ), 'test_wp_cache_flush_group: group-test should return false' );447 $this->assertSame( $val, wp_cache_get( $key, 'group-kept' ), 'test_wp_cache_flush_group: group-kept should still contain my-val' );448 }449 }450 448 } -
trunk/tests/phpunit/tests/pluggable.php
r53763 r53767 269 269 // wp-includes/cache.php: 270 270 'wp_cache_init' => array(), 271 'wp_cache_supports_group_flush' => array(),272 271 'wp_cache_add' => array( 273 272 'key', … … 330 329 'wp_cache_flush_runtime' => array(), 331 330 'wp_cache_flush_group' => array( 'group' ), 331 332 332 'wp_cache_close' => array(), 333 333 'wp_cache_add_global_groups' => array( 'groups' ),
Note: See TracChangeset
for help on using the changeset viewer.