diff --git wp-cron.php wp-cron.php
index 04953c8..21706cb 100644
|
|
if ( !defined('ABSPATH') ) { |
28 | 28 | |
29 | 29 | // Uncached doing_cron transient fetch |
30 | 30 | function _get_cron_lock() { |
31 | | global $_wp_using_ext_object_cache, $wpdb; |
| 31 | global $wpdb; |
32 | 32 | |
33 | 33 | $value = 0; |
34 | | if ( $_wp_using_ext_object_cache ) { |
| 34 | if ( wp_using_ext_object_cache() ) { |
35 | 35 | // Skip local cache and force refetch of doing_cron transient in case |
36 | 36 | // another processs updated the cache |
37 | 37 | $value = wp_cache_get( 'doing_cron', 'transient', true ); |
diff --git wp-includes/load.php wp-includes/load.php
index e1eb15e..6fb608b 100644
|
|
function wp_set_wpdb_vars() { |
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
| 373 | * Access/Modify private global variable $_wp_using_ext_object_cache |
| 374 | * |
| 375 | * Toggle $_wp_using_ext_object_cache on and off without directly touching global |
| 376 | * |
| 377 | * @since 3.7.0 |
| 378 | * |
| 379 | * @param bool $using Whether external object cache is being used |
| 380 | * @return bool The current 'using' setting |
| 381 | */ |
| 382 | function wp_using_ext_object_cache( $using = null ) { |
| 383 | global $_wp_using_ext_object_cache; |
| 384 | $current_using = $_wp_using_ext_object_cache; |
| 385 | if ( null !== $using ) |
| 386 | $_wp_using_ext_object_cache = $using; |
| 387 | return $current_using; |
| 388 | } |
| 389 | |
| 390 | /** |
373 | 391 | * Starts the WordPress object cache. |
374 | 392 | * |
375 | 393 | * If an object-cache.php file exists in the wp-content directory, |
… |
… |
function wp_set_wpdb_vars() { |
379 | 397 | * @since 3.0.0 |
380 | 398 | */ |
381 | 399 | function wp_start_object_cache() { |
382 | | global $_wp_using_ext_object_cache, $blog_id; |
| 400 | global $blog_id; |
383 | 401 | |
384 | 402 | $first_init = false; |
385 | 403 | if ( ! function_exists( 'wp_cache_init' ) ) { |
386 | 404 | if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
387 | 405 | require_once ( WP_CONTENT_DIR . '/object-cache.php' ); |
388 | | $_wp_using_ext_object_cache = true; |
389 | | } else { |
390 | | require_once ( ABSPATH . WPINC . '/cache.php' ); |
391 | | $_wp_using_ext_object_cache = false; |
| 406 | if ( function_exists( 'wp_cache_init' ) ) |
| 407 | wp_using_ext_object_cache( true ); |
392 | 408 | } |
| 409 | |
393 | 410 | $first_init = true; |
394 | | } else if ( !$_wp_using_ext_object_cache && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
| 411 | } else if ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
395 | 412 | // Sometimes advanced-cache.php can load object-cache.php before it is loaded here. |
396 | 413 | // This breaks the function_exists check above and can result in $_wp_using_ext_object_cache |
397 | 414 | // being set incorrectly. Double check if an external cache exists. |
398 | | $_wp_using_ext_object_cache = true; |
| 415 | wp_using_ext_object_cache( true ); |
399 | 416 | } |
400 | 417 | |
| 418 | if ( ! wp_using_ext_object_cache() ) |
| 419 | require_once ( ABSPATH . WPINC . '/cache.php' ); |
| 420 | |
401 | 421 | // If cache supports reset, reset instead of init if already initialized. |
402 | 422 | // Reset signals to the cache that global IDs have changed and it may need to update keys |
403 | 423 | // and cleanup caches. |
404 | 424 | if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) |
405 | 425 | wp_cache_switch_to_blog( $blog_id ); |
406 | | else |
| 426 | elseif ( function_exists( 'wp_cache_init' ) ) |
407 | 427 | wp_cache_init(); |
408 | 428 | |
409 | 429 | if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
diff --git wp-includes/nav-menu.php wp-includes/nav-menu.php
index 794f4b2..9d7219f 100644
|
|
function _is_valid_nav_menu_item( $item ) { |
476 | 476 | * @return mixed $items array of menu items, else false. |
477 | 477 | */ |
478 | 478 | function wp_get_nav_menu_items( $menu, $args = array() ) { |
479 | | global $_wp_using_ext_object_cache; |
480 | | |
481 | 479 | $menu = wp_get_nav_menu_object( $menu ); |
482 | 480 | |
483 | 481 | if ( ! $menu ) |
… |
… |
function wp_get_nav_menu_items( $menu, $args = array() ) { |
504 | 502 | return false; |
505 | 503 | |
506 | 504 | // Get all posts and terms at once to prime the caches |
507 | | if ( empty( $fetched[$menu->term_id] ) || $_wp_using_ext_object_cache ) { |
| 505 | if ( empty( $fetched[$menu->term_id] ) || wp_using_ext_object_cache() ) { |
508 | 506 | $fetched[$menu->term_id] = true; |
509 | 507 | $posts = array(); |
510 | 508 | $terms = array(); |
diff --git wp-includes/option.php wp-includes/option.php
index 3df89c2..5919f04 100644
|
|
function wp_load_alloptions() { |
165 | 165 | * @param int $site_id Optional site ID for which to query the options. Defaults to the current site. |
166 | 166 | */ |
167 | 167 | function wp_load_core_site_options( $site_id = null ) { |
168 | | global $wpdb, $_wp_using_ext_object_cache; |
| 168 | global $wpdb; |
169 | 169 | |
170 | | if ( !is_multisite() || $_wp_using_ext_object_cache || defined( 'WP_INSTALLING' ) ) |
| 170 | if ( !is_multisite() || wp_using_ext_object_cache() || defined( 'WP_INSTALLING' ) ) |
171 | 171 | return; |
172 | 172 | |
173 | 173 | if ( empty($site_id) ) |
… |
… |
function delete_option( $option ) { |
404 | 404 | * @return bool true if successful, false otherwise |
405 | 405 | */ |
406 | 406 | function delete_transient( $transient ) { |
407 | | global $_wp_using_ext_object_cache; |
408 | | |
409 | 407 | do_action( 'delete_transient_' . $transient, $transient ); |
410 | 408 | |
411 | | if ( $_wp_using_ext_object_cache ) { |
| 409 | if ( wp_using_ext_object_cache() ) { |
412 | 410 | $result = wp_cache_delete( $transient, 'transient' ); |
413 | 411 | } else { |
414 | 412 | $option_timeout = '_transient_timeout_' . $transient; |
… |
… |
function delete_transient( $transient ) { |
443 | 441 | * @return mixed Value of transient |
444 | 442 | */ |
445 | 443 | function get_transient( $transient ) { |
446 | | global $_wp_using_ext_object_cache; |
447 | | |
448 | 444 | $pre = apply_filters( 'pre_transient_' . $transient, false ); |
449 | 445 | if ( false !== $pre ) |
450 | 446 | return $pre; |
451 | 447 | |
452 | | if ( $_wp_using_ext_object_cache ) { |
| 448 | if ( wp_using_ext_object_cache() ) { |
453 | 449 | $value = wp_cache_get( $transient, 'transient' ); |
454 | 450 | } else { |
455 | 451 | $transient_option = '_transient_' . $transient; |
… |
… |
function get_transient( $transient ) { |
492 | 488 | * @return bool False if value was not set and true if value was set. |
493 | 489 | */ |
494 | 490 | function set_transient( $transient, $value, $expiration = 0 ) { |
495 | | global $_wp_using_ext_object_cache; |
496 | | |
497 | 491 | $value = apply_filters( 'pre_set_transient_' . $transient, $value ); |
498 | 492 | |
499 | | if ( $_wp_using_ext_object_cache ) { |
| 493 | if ( wp_using_ext_object_cache() ) { |
500 | 494 | $result = wp_cache_set( $transient, $value, 'transient', $expiration ); |
501 | 495 | } else { |
502 | 496 | $transient_timeout = '_transient_timeout_' . $transient; |
… |
… |
function update_site_option( $option, $value ) { |
945 | 939 | * @return bool True if successful, false otherwise |
946 | 940 | */ |
947 | 941 | function delete_site_transient( $transient ) { |
948 | | global $_wp_using_ext_object_cache; |
949 | | |
950 | 942 | do_action( 'delete_site_transient_' . $transient, $transient ); |
951 | | if ( $_wp_using_ext_object_cache ) { |
| 943 | if ( wp_using_ext_object_cache() ) { |
952 | 944 | $result = wp_cache_delete( $transient, 'site-transient' ); |
953 | 945 | } else { |
954 | 946 | $option_timeout = '_site_transient_timeout_' . $transient; |
… |
… |
function delete_site_transient( $transient ) { |
983 | 975 | * @return mixed Value of transient |
984 | 976 | */ |
985 | 977 | function get_site_transient( $transient ) { |
986 | | global $_wp_using_ext_object_cache; |
987 | | |
988 | 978 | $pre = apply_filters( 'pre_site_transient_' . $transient, false ); |
989 | 979 | if ( false !== $pre ) |
990 | 980 | return $pre; |
991 | 981 | |
992 | | if ( $_wp_using_ext_object_cache ) { |
| 982 | if ( wp_using_ext_object_cache() ) { |
993 | 983 | $value = wp_cache_get( $transient, 'site-transient' ); |
994 | 984 | } else { |
995 | 985 | // Core transients that do not have a timeout. Listed here so querying timeouts can be avoided. |
… |
… |
function get_site_transient( $transient ) { |
1032 | 1022 | * @return bool False if value was not set and true if value was set. |
1033 | 1023 | */ |
1034 | 1024 | function set_site_transient( $transient, $value, $expiration = 0 ) { |
1035 | | global $_wp_using_ext_object_cache; |
1036 | | |
1037 | 1025 | $value = apply_filters( 'pre_set_site_transient_' . $transient, $value ); |
1038 | 1026 | |
1039 | | if ( $_wp_using_ext_object_cache ) { |
| 1027 | if ( wp_using_ext_object_cache() ) { |
1040 | 1028 | $result = wp_cache_set( $transient, $value, 'site-transient', $expiration ); |
1041 | 1029 | } else { |
1042 | 1030 | $transient_timeout = '_site_transient_timeout_' . $transient; |
diff --git wp-includes/query.php wp-includes/query.php
index 04286aa..493b180 100644
|
|
class WP_Query { |
1917 | 1917 | * @return array List of posts. |
1918 | 1918 | */ |
1919 | 1919 | function get_posts() { |
1920 | | global $wpdb, $user_ID, $_wp_using_ext_object_cache; |
| 1920 | global $wpdb, $user_ID; |
1921 | 1921 | |
1922 | 1922 | $this->parse_query(); |
1923 | 1923 | |
… |
… |
class WP_Query { |
1967 | 1967 | $q['suppress_filters'] = false; |
1968 | 1968 | |
1969 | 1969 | if ( !isset($q['cache_results']) ) { |
1970 | | if ( $_wp_using_ext_object_cache ) |
| 1970 | if ( wp_using_ext_object_cache() ) |
1971 | 1971 | $q['cache_results'] = false; |
1972 | 1972 | else |
1973 | 1973 | $q['cache_results'] = true; |
diff --git wp-settings.php wp-settings.php
index 1094749..5d4f72b 100644
|
|
timer_start(); |
54 | 54 | wp_debug_mode(); |
55 | 55 | |
56 | 56 | // For an advanced caching plugin to use. Uses a static drop-in because you would only want one. |
57 | | if ( WP_CACHE ) |
| 57 | if ( WP_CACHE && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) |
58 | 58 | WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' ); |
59 | 59 | |
60 | 60 | // Define WP_LANG_DIR if not set. |