Ticket #31245: 31245-1.diff
File 31245-1.diff, 7.1 KB (added by , 9 years ago) |
---|
-
wp-admin/includes/update-core.php
1085 1085 // Clear the cache to prevent an update_option() from saving a stale db_version to the cache 1086 1086 wp_cache_flush(); 1087 1087 // (Not all cache backends listen to 'flush') 1088 wp_cache_delete( 'alloptions ', 'options' );1088 wp_cache_delete( 'alloptionskeys', 'options' ); 1089 1089 1090 1090 // Remove working directory 1091 1091 $wp_filesystem->delete($from, true); -
wp-includes/cache.php
124 124 } 125 125 126 126 /** 127 * Retrieve multiple cache items. 128 * 129 * @param array $groups Associative array of cache groups to cache keys to fetch. 130 * @param string $force Whether to force a refetch rather than relying on the local cache (default is false). 131 * @return false|array False on failure or cache contents on success as an two-level associative array, keyed by group and cache key. 132 */ 133 function wp_cache_get_multi( $groups, $force = false ) { 134 global $wp_object_cache; 135 136 return $wp_object_cache->get_multi( $groups, $force ); 137 } 138 139 /** 127 140 * Increment numeric cache item's value 128 141 * 129 142 * @since 3.3.0 … … 444 457 } 445 458 446 459 /** 460 * Retrieve multiple cache items. 461 * 462 * @param array $groups Associative array of cache groups to cache keys to fetch. 463 * @param string $force Whether to force a refetch rather than relying on the local cache (default is false). 464 * @return false|array False on failure or cache contents on success as an two-level associative array, keyed by group and cache key. 465 */ 466 public function get_multi( $groups, $force = false ) { 467 $data = array(); 468 469 foreach ( $groups as $group => $keys ) { 470 $data[ $group ] = array(); 471 472 foreach ( $keys as $key ) { 473 $value = $this->get( $key, $group, $force, $found ); 474 if ( ! $found ) { 475 continue; 476 } 477 478 $data[ $group ][ $key ] = $value; 479 } 480 } 481 482 return $data; 483 } 484 485 /** 447 486 * Decrements numeric cache item's value. 448 487 * 449 488 * @since 3.3.0 -
wp-includes/load.php
479 479 } 480 480 481 481 /** 482 * Retrieve multiple cache items. 483 * 484 * Note: This should be used only as a fallback if `wp_cache_get_multi` is not 485 * defined for the current object cache. 486 * 487 * @param array $groups Associative array of cache groups to cache keys to fetch. 488 * @param string $force Whether to force a refetch rather than relying on the local cache (default is false). 489 * @return false|array False on failure or cache contents on success as an two-level associative array, keyed by group and cache key. 490 */ 491 function _wp_cache_compat_get_multi( $groups, $force = false ) { 492 $data = array(); 493 494 foreach ( $groups as $group => $keys ) { 495 $data[ $group ] = array(); 496 497 foreach ( $keys as $key ) { 498 $value = wp_cache_get( $key, $group, $force ); 499 if ( ! $value ) { 500 continue; 501 } 502 503 $data[ $group ][ $key ] = $value; 504 } 505 } 506 507 return $data; 508 } 509 510 /** 482 511 * Redirect to the installer if WordPress is not installed. 483 512 * 484 513 * Dies with an error message when Multisite is enabled. -
wp-includes/option.php
144 144 * @param string $option Option name. 145 145 */ 146 146 function wp_protect_special_option( $option ) { 147 if ( 'alloptions' === $option || ' notoptions' === $option )147 if ( 'alloptions' === $option || 'alloptionskeys' === $option || 'notoptions' === $option ) 148 148 wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) ); 149 149 } 150 150 … … 171 171 function wp_load_alloptions() { 172 172 global $wpdb; 173 173 174 if ( ! wp_installing() || ! is_multisite() ) 175 $alloptions = wp_cache_get( 'alloptions', 'options' ); 176 else 177 $alloptions = false; 174 $alloptions = false; 178 175 176 if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) { 177 $keys = wp_cache_get( 'alloptionskeys', 'options' ); 178 if ( is_array( $keys ) ) { 179 if ( function_exists( 'wp_cache_get_multi' ) ) { 180 $cached_options = wp_cache_get_multi( array( 'options' => array_keys( $keys ) ) ); 181 } else { 182 $cached_options = _wp_cache_compat_get_multi( array( 'options' => array_keys( $keys ) ) ); 183 } 184 $alloptions = $cached_options['options']; 185 } 186 } 187 179 188 if ( !$alloptions ) { 180 189 $suppress = $wpdb->suppress_errors(); 181 190 if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) … … 182 191 $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); 183 192 $wpdb->suppress_errors($suppress); 184 193 $alloptions = array(); 194 $keys = array(); 185 195 foreach ( (array) $alloptions_db as $o ) { 186 196 $alloptions[$o->option_name] = $o->option_value; 197 $keys[ $o->option_name ] = true; 187 198 } 188 if ( ! wp_installing() || ! is_multisite() ) 189 wp_cache_add( 'alloptions', $alloptions, 'options' ); 199 200 if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) { 201 wp_cache_add( 'alloptionskeys', $keys, 'options' ); 202 203 foreach ( $alloptions as $key => $value ) { 204 wp_cache_set( $key, $value, 'options' ); 205 } 206 } 190 207 } 191 208 192 209 return $alloptions; … … 333 350 } 334 351 335 352 if ( ! wp_installing() ) { 336 $alloptions = wp_load_alloptions(); 337 if ( isset( $alloptions[$option] ) ) { 338 $alloptions[ $option ] = $serialized_value; 339 wp_cache_set( 'alloptions', $alloptions, 'options' ); 340 } else { 341 wp_cache_set( $option, $serialized_value, 'options' ); 342 } 353 wp_cache_set( $option, $serialized_value, 'options' ); 343 354 } 344 355 345 356 /** … … 435 446 436 447 if ( ! wp_installing() ) { 437 448 if ( 'yes' == $autoload ) { 438 $alloptions = wp_load_alloptions(); 439 $alloptions[ $option ] = $serialized_value; 440 wp_cache_set( 'alloptions', $alloptions, 'options' ); 441 } else { 442 wp_cache_set( $option, $serialized_value, 'options' ); 449 $alloptionskeys = wp_cache_get( 'alloptionskeys', 'options' ); 450 $alloptionskeys[ $option ] = true; 451 wp_cache_set( 'alloptionskeys', $alloptionskeys, 'options' ); 443 452 } 453 454 wp_cache_set( $option, $serialized_value, 'options' ); 444 455 } 445 456 446 457 // This option exists now … … 511 522 $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); 512 523 if ( ! wp_installing() ) { 513 524 if ( 'yes' == $row->autoload ) { 514 $alloptions = wp_load_alloptions();515 if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) {516 unset( $alloptions [$option] );517 wp_cache_set( 'alloptions ', $alloptions, 'options' );525 $alloptionskeys = wp_cache_get( 'alloptionskeys', 'options' ); 526 if ( is_array( $alloptionskeys ) && isset( $alloptionskeys[$option] ) ) { 527 unset( $alloptionskeys[$option] ); 528 wp_cache_set( 'alloptionskeys', $alloptionskeys, 'options' ); 518 529 } 519 } else {520 wp_cache_delete( $option, 'options' );521 530 } 531 532 wp_cache_delete( $option, 'options' ); 522 533 } 523 534 if ( $result ) { 524 535