diff --git src/wp-includes/cache.php src/wp-includes/cache.php
index ea14e78b4d..6c44c4ac32 100644
|
|
|
function wp_cache_get( $key, $group = '', $force = false, &$found = null ) { |
| 123 | 123 | return $wp_object_cache->get( $key, $group, $force, $found ); |
| 124 | 124 | } |
| 125 | 125 | |
| | 126 | /** |
| | 127 | * Gets multiple values from cache in one call. |
| | 128 | * |
| | 129 | * @since 5.4.0 |
| | 130 | * @uses $wp_object_cache Object Cache Class |
| | 131 | * |
| | 132 | * @param array $keys Array of keys to get from group. |
| | 133 | * @param string $group Optional. Where the cache contents are grouped. Default empty. |
| | 134 | * @param bool $force Optional. Whether to force an update of the local cache from the persistent |
| | 135 | * cache. Default false. |
| | 136 | * @return array|bool Array of values. |
| | 137 | */ |
| | 138 | function wp_cache_multiple_get( $keys, $group = '', $force = false ) { |
| | 139 | global $wp_object_cache; |
| | 140 | |
| | 141 | return $wp_object_cache->get_multiple( $keys, $group, $force ); |
| | 142 | } |
| | 143 | |
| 126 | 144 | /** |
| 127 | 145 | * Increment numeric cache item's value |
| 128 | 146 | * |
| … |
… |
class WP_Object_Cache { |
| 566 | 584 | return false; |
| 567 | 585 | } |
| 568 | 586 | |
| | 587 | /** |
| | 588 | * Retrieves multiple values from the cache. |
| | 589 | * |
| | 590 | * @since 5.4.0 |
| | 591 | * |
| | 592 | * @param array $keys Array of keys to fetch. |
| | 593 | * @param bool $force Optional. Unused. Whether to force a refetch rather than relying on the local |
| | 594 | * cache. Default false. |
| | 595 | * |
| | 596 | * @return array Array of values organized into groups. |
| | 597 | */ |
| | 598 | public function get_multiple( $keys, $group = 'default', $force = false ) { |
| | 599 | $values = array(); |
| | 600 | |
| | 601 | foreach ( $keys as $key ) { |
| | 602 | $values[ $key ] = $this->get( $key, $group, $force ); |
| | 603 | } |
| | 604 | |
| | 605 | return $values; |
| | 606 | } |
| | 607 | |
| 569 | 608 | /** |
| 570 | 609 | * Increments numeric cache item's value. |
| 571 | 610 | * |
diff --git src/wp-includes/load.php src/wp-includes/load.php
index 9a24cfad4b..d8873dcba0 100644
|
|
|
function wp_not_installed() { |
| 614 | 614 | wp_redirect( $link ); |
| 615 | 615 | die(); |
| 616 | 616 | } |
| | 617 | |
| | 618 | if ( ! function_exists( 'wp_cache_multiple_get' ) ) { |
| | 619 | require_once( ABSPATH . WPINC . '/cache-compat.php' ); |
| | 620 | } |
| 617 | 621 | } |
| 618 | 622 | |
| 619 | 623 | /** |
diff --git tests/phpunit/tests/cache.php tests/phpunit/tests/cache.php
index a9534f875c..ac910fe0cb 100644
|
|
|
class Tests_Cache extends WP_UnitTestCase { |
| 315 | 315 | // Make sure $fake_key is not stored. |
| 316 | 316 | $this->assertFalse( wp_cache_get( $fake_key ) ); |
| 317 | 317 | } |
| | 318 | |
| | 319 | /** |
| | 320 | * @ticket 20875 |
| | 321 | */ |
| | 322 | public function test_get_multiple() { |
| | 323 | wp_cache_set( 'foo1', 'bar', 'group1' ); |
| | 324 | wp_cache_set( 'foo2', 'bar', 'group1' ); |
| | 325 | wp_cache_set( 'foo1', 'bar', 'group2' ); |
| | 326 | |
| | 327 | $found = wp_cache_multiple_get( array( 'foo1', 'foo2', 'foo3', ), 'group1' ); |
| | 328 | |
| | 329 | $expected = array( |
| | 330 | 'foo1' => 'bar', |
| | 331 | 'foo2' => 'bar', |
| | 332 | 'foo3' => false, |
| | 333 | ); |
| | 334 | |
| | 335 | $this->assertSame( $expected, $found ); |
| | 336 | } |
| 318 | 337 | } |
diff --git tests/phpunit/tests/pluggable.php tests/phpunit/tests/pluggable.php
index 73ca7de806..48a7d3ac00 100644
|
|
|
class Tests_Pluggable extends WP_UnitTestCase { |
| 290 | 290 | 'force' => false, |
| 291 | 291 | 'found' => null, |
| 292 | 292 | ), |
| | 293 | 'wp_cache_multiple_get' => array( |
| | 294 | 'keys', |
| | 295 | 'group' => '', |
| | 296 | 'force' => false, |
| | 297 | ), |
| 293 | 298 | 'wp_cache_incr' => array( |
| 294 | 299 | 'key', |
| 295 | 300 | 'offset' => 1, |