diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php
index 8c94796..ec00f70 100644
a
|
b
|
function update_core($from, $to) { |
1020 | 1020 | // Clear the cache to prevent an update_option() from saving a stale db_version to the cache |
1021 | 1021 | wp_cache_flush(); |
1022 | 1022 | // (Not all cache backends listen to 'flush') |
1023 | | wp_cache_delete( 'alloptions', 'options' ); |
| 1023 | wp_cache_delete( 'alloptionskeys', 'options' ); |
1024 | 1024 | |
1025 | 1025 | // Remove working directory |
1026 | 1026 | $wp_filesystem->delete($from, true); |
diff --git a/wp-includes/cache.php b/wp-includes/cache.php
index 5264fe2..1aa3c1c 100644
a
|
b
|
function wp_cache_get( $key, $group = '', $force = false, &$found = null ) { |
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
| 117 | * Retrieve multiple cache items. |
| 118 | * |
| 119 | * @param array $groups Associative array of cache groups to cache keys to fetch. |
| 120 | * @param string $force Whether to force a refetch rather than relying on the local cache (default is false). |
| 121 | * @return false|array False on failure or cache contents on success as an two-level associative array, keyed by group and cache key. |
| 122 | */ |
| 123 | function wp_cache_get_multi( $groups, $force = false ) { |
| 124 | global $wp_object_cache; |
| 125 | |
| 126 | return $wp_object_cache->get_multi( $groups, $force ); |
| 127 | } |
| 128 | |
| 129 | /** |
117 | 130 | * Increment numeric cache item's value |
118 | 131 | * |
119 | 132 | * @since 3.3.0 |
… |
… |
class WP_Object_Cache { |
516 | 529 | } |
517 | 530 | |
518 | 531 | /** |
| 532 | * Retrieve multiple cache items. |
| 533 | * |
| 534 | * @param array $groups Associative array of cache groups to cache keys to fetch. |
| 535 | * @param string $force Whether to force a refetch rather than relying on the local cache (default is false). |
| 536 | * @return false|array False on failure or cache contents on success as an two-level associative array, keyed by group and cache key. |
| 537 | */ |
| 538 | public function get_multi( $groups, $force = false ) { |
| 539 | $data = array(); |
| 540 | |
| 541 | foreach ( $groups as $group => $keys ) { |
| 542 | $data[ $group ] = array(); |
| 543 | |
| 544 | foreach ( $keys as $key ) { |
| 545 | $value = $this->get( $key, $group, $force, $found ); |
| 546 | if ( ! $found ) { |
| 547 | continue; |
| 548 | } |
| 549 | |
| 550 | $data[ $group ][ $key ] = $value; |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | return $data; |
| 555 | } |
| 556 | |
| 557 | /** |
519 | 558 | * Increment numeric cache item's value |
520 | 559 | * |
521 | 560 | * @since 3.3.0 |
diff --git a/wp-includes/load.php b/wp-includes/load.php
index 07f2283..cbc6e46 100644
a
|
b
|
function wp_start_object_cache() { |
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
| 460 | * Retrieve multiple cache items. |
| 461 | * |
| 462 | * Note: This should be used only as a fallback if `wp_cache_get_multi` is not |
| 463 | * defined for the current object cache. |
| 464 | * |
| 465 | * @param array $groups Associative array of cache groups to cache keys to fetch. |
| 466 | * @param string $force Whether to force a refetch rather than relying on the local cache (default is false). |
| 467 | * @return false|array False on failure or cache contents on success as an two-level associative array, keyed by group and cache key. |
| 468 | */ |
| 469 | function _wp_cache_compat_get_multi( $groups, $force = false ) { |
| 470 | $data = array(); |
| 471 | |
| 472 | foreach ( $groups as $group => $keys ) { |
| 473 | $data[ $group ] = array(); |
| 474 | |
| 475 | foreach ( $keys as $key ) { |
| 476 | $value = wp_cache_get( $key, $group, $force ); |
| 477 | if ( ! $value ) { |
| 478 | continue; |
| 479 | } |
| 480 | |
| 481 | $data[ $group ][ $key ] = $value; |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | return $data; |
| 486 | } |
| 487 | |
| 488 | /** |
460 | 489 | * Redirect to the installer if WordPress is not installed. |
461 | 490 | * |
462 | 491 | * Dies with an error message when Multisite is enabled. |
diff --git a/wp-includes/option.php b/wp-includes/option.php
index c6417db..dbe8627 100644
a
|
b
|
function get_option( $option, $default = false ) { |
134 | 134 | * @param string $option Option name. |
135 | 135 | */ |
136 | 136 | function wp_protect_special_option( $option ) { |
137 | | if ( 'alloptions' === $option || 'notoptions' === $option ) |
| 137 | if ( 'alloptions' === $option || 'alloptionskeys' === $option || 'notoptions' === $option ) |
138 | 138 | wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) ); |
139 | 139 | } |
140 | 140 | |
… |
… |
function form_option( $option ) { |
160 | 160 | function wp_load_alloptions() { |
161 | 161 | global $wpdb; |
162 | 162 | |
163 | | if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) |
164 | | $alloptions = wp_cache_get( 'alloptions', 'options' ); |
165 | | else |
166 | | $alloptions = false; |
| 163 | $alloptions = false; |
| 164 | |
| 165 | if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) { |
| 166 | $keys = wp_cache_get( 'alloptionskeys', 'options' ); |
| 167 | if ( is_array( $keys ) ) { |
| 168 | if ( function_exists( 'wp_cache_get_multi' ) ) { |
| 169 | $cached_options = wp_cache_get_multi( array( 'options' => array_keys( $keys ) ) ); |
| 170 | } |
| 171 | else { |
| 172 | $cached_options = _wp_cache_compat_get_multi( array( 'options' => array_keys( $keys ) ) ); |
| 173 | } |
| 174 | $alloptions = $cached_options['options']; |
| 175 | } |
| 176 | } |
167 | 177 | |
168 | 178 | if ( !$alloptions ) { |
169 | 179 | $suppress = $wpdb->suppress_errors(); |
… |
… |
function wp_load_alloptions() { |
171 | 181 | $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); |
172 | 182 | $wpdb->suppress_errors($suppress); |
173 | 183 | $alloptions = array(); |
| 184 | $keys = array(); |
174 | 185 | foreach ( (array) $alloptions_db as $o ) { |
175 | 186 | $alloptions[$o->option_name] = $o->option_value; |
| 187 | $keys[ $o->option_name ] = true; |
| 188 | } |
| 189 | |
| 190 | if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) { |
| 191 | wp_cache_add( 'alloptionskeys', $keys, 'options' ); |
| 192 | |
| 193 | foreach ( $alloptions as $key => $value ) { |
| 194 | wp_cache_set( $key, $value, 'options' ); |
| 195 | } |
176 | 196 | } |
177 | | if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) |
178 | | wp_cache_add( 'alloptions', $alloptions, 'options' ); |
179 | 197 | } |
180 | 198 | |
181 | 199 | return $alloptions; |
… |
… |
function update_option( $option, $value ) { |
297 | 315 | } |
298 | 316 | |
299 | 317 | if ( ! defined( 'WP_INSTALLING' ) ) { |
300 | | $alloptions = wp_load_alloptions(); |
301 | | if ( isset( $alloptions[$option] ) ) { |
302 | | $alloptions[ $option ] = $serialized_value; |
303 | | wp_cache_set( 'alloptions', $alloptions, 'options' ); |
304 | | } else { |
305 | | wp_cache_set( $option, $serialized_value, 'options' ); |
306 | | } |
| 318 | wp_cache_set( $option, $serialized_value, 'options' ); |
307 | 319 | } |
308 | 320 | |
309 | 321 | /** |
… |
… |
function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) |
393 | 405 | |
394 | 406 | if ( ! defined( 'WP_INSTALLING' ) ) { |
395 | 407 | if ( 'yes' == $autoload ) { |
396 | | $alloptions = wp_load_alloptions(); |
397 | | $alloptions[ $option ] = $serialized_value; |
398 | | wp_cache_set( 'alloptions', $alloptions, 'options' ); |
399 | | } else { |
400 | | wp_cache_set( $option, $serialized_value, 'options' ); |
| 408 | $alloptionskeys = wp_cache_get( 'alloptionskeys', 'options' ); |
| 409 | $alloptionskeys[ $option ] = true; |
| 410 | wp_cache_set( 'alloptionskeys', $alloptionskeys, 'options' ); |
401 | 411 | } |
| 412 | |
| 413 | wp_cache_set( $option, $serialized_value, 'options' ); |
402 | 414 | } |
403 | 415 | |
404 | 416 | // This option exists now |
… |
… |
function delete_option( $option ) { |
467 | 479 | $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); |
468 | 480 | if ( ! defined( 'WP_INSTALLING' ) ) { |
469 | 481 | if ( 'yes' == $row->autoload ) { |
470 | | $alloptions = wp_load_alloptions(); |
471 | | if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) { |
472 | | unset( $alloptions[$option] ); |
473 | | wp_cache_set( 'alloptions', $alloptions, 'options' ); |
| 482 | $alloptionskeys = wp_cache_get( 'alloptionskeys', 'options' ); |
| 483 | if ( is_array( $alloptionskeys ) && isset( $alloptionskeys[$option] ) ) { |
| 484 | unset( $alloptionskeys[$option] ); |
| 485 | wp_cache_set( 'alloptionskeys', $alloptionskeys, 'options' ); |
474 | 486 | } |
475 | | } else { |
476 | | wp_cache_delete( $option, 'options' ); |
477 | 487 | } |
| 488 | |
| 489 | wp_cache_delete( $option, 'options' ); |
478 | 490 | } |
479 | 491 | if ( $result ) { |
480 | 492 | |