diff --git src/wp-includes/load.php src/wp-includes/load.php
index 704e24472f..e3fee133ec 100644
|
|
function wp_using_ext_object_cache( $using = null ) { |
530 | 530 | */ |
531 | 531 | function wp_start_object_cache() { |
532 | 532 | global $wp_filter; |
| 533 | static $first_init = true; |
| 534 | |
| 535 | // Only perform the following checks once. |
| 536 | if ( $first_init ) { |
| 537 | if ( ! function_exists( 'wp_cache_init' ) ) { |
| 538 | /* |
| 539 | * This is the normal situation. First-run of this function. No |
| 540 | * caching backend has been loaded. |
| 541 | * |
| 542 | * We try to load a custom caching backend, and then, if it |
| 543 | * results in a wp_cache_init() function existing, we note |
| 544 | * that an external object cache is being used. |
| 545 | */ |
| 546 | if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
| 547 | require_once ( WP_CONTENT_DIR . '/object-cache.php' ); |
| 548 | if ( function_exists( 'wp_cache_init' ) ) { |
| 549 | wp_using_ext_object_cache( true ); |
| 550 | } |
533 | 551 | |
534 | | $first_init = false; |
535 | | if ( ! function_exists( 'wp_cache_init' ) ) { |
536 | | if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
537 | | require_once( WP_CONTENT_DIR . '/object-cache.php' ); |
538 | | if ( function_exists( 'wp_cache_init' ) ) { |
539 | | wp_using_ext_object_cache( true ); |
540 | | } |
541 | | |
542 | | // Re-initialize any hooks added manually by object-cache.php |
543 | | if ( $wp_filter ) { |
544 | | $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); |
| 552 | // Re-initialize any hooks added manually by object-cache.php |
| 553 | if ( $wp_filter ) { |
| 554 | $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); |
| 555 | } |
545 | 556 | } |
| 557 | } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
| 558 | /* |
| 559 | * Sometimes advanced-cache.php can load object-cache.php before |
| 560 | * this function is run. This breaks the function_exists() check |
| 561 | * above and can result in wp_using_ext_object_cache() returning |
| 562 | * false when actually an external cache is in use. |
| 563 | */ |
| 564 | wp_using_ext_object_cache( true ); |
546 | 565 | } |
547 | | |
548 | | $first_init = true; |
549 | | } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
550 | | /* |
551 | | * Sometimes advanced-cache.php can load object-cache.php before |
552 | | * it is loaded here. This breaks the function_exists check above |
553 | | * and can result in `$_wp_using_ext_object_cache` being set |
554 | | * incorrectly. Double check if an external cache exists. |
555 | | */ |
556 | | wp_using_ext_object_cache( true ); |
557 | 566 | } |
558 | 567 | |
559 | 568 | if ( ! wp_using_ext_object_cache() ) { |
560 | | require_once( ABSPATH . WPINC . '/cache.php' ); |
| 569 | require_once ( ABSPATH . WPINC . '/cache.php' ); |
561 | 570 | } |
562 | 571 | |
563 | 572 | /* |
… |
… |
function wp_start_object_cache() { |
575 | 584 | wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); |
576 | 585 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); |
577 | 586 | } |
| 587 | |
| 588 | $first_init = false; |
578 | 589 | } |
579 | 590 | |
580 | 591 | /** |